Why this code is legal???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nadavvin
Forum Commoner
Posts: 68
Joined: Wed Sep 06, 2006 6:05 am

Why this code is legal???

Post 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
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Why this code is legal???

Post by Celauran »

nadavvin
Forum Commoner
Posts: 68
Joined: Wed Sep 06, 2006 6:05 am

Re: Why this code is legal???

Post by nadavvin »

thanks
Post Reply