tags:

views:

21

answers:

2

I always thought that the arguments of a function in PHP should be either a string enclosed by '', or a number, or a variable.

However, looking at this in php.net's manual I see:

   public function baz(Test $other)

What does the word Test here refer to?

How is this possible?

+2  A: 

PHP 5 supports "type hinting" for object or array parameters. If $other is not a Test object, there will be a runtime fatal error.

So make sure you catch the hint.

Matthew Flaschen
A: 

It means the argument to baz() should be of type Test.

pjmorse
It means it *must* be of type Test. Otherwise you get a catchable fatal error.
konforce