Page 1 of 1

Why this code is legal???

Posted: Thu Mar 22, 2012 10:22 am
by nadavvin

Code: Select all

class A{}
class B{
    function a(\A $a) {
        return $a;
     }
 }

$c=new A();
$d=new B();
print_r($d->a($c));
[text]A Object
(
)[/text]

What does the backslash \ do before the class type ?

I didn't found it on the PHP documentation

although I didn't find the syntax function:

Code: Select all

func_name(CLASS_NAME $prop){}
there also

Re: Why this code is legal???

Posted: Thu Mar 22, 2012 10:43 am
by Celauran

Re: Why this code is legal???

Posted: Thu Mar 22, 2012 10:59 am
by nadavvin
thanks