In this example the class constructor receives only
int
parameter. If any other type is passed, fatal error will be generated
class Book {
    public $price;
    
    public function price(int $price) {
        $this->price = $price;
    }
}

$book = new Book;

$book->price('k34');

echo $book->price;
Fatal error:
Uncaught TypeError: Argument 1 passed to Book::price() must be of the type int, string given
by Valeri Tandilashvili
4 years ago
PHP
OOP
OOP PHP
2
Pro tip: use ```triple backticks around text``` to write in code fences