Re: function names

From: Date: Thu, 25 Oct 2001 19:09:18 +0000
Subject: Re: function names
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-72326@lists.php.net to get a copy of this message
Actually your problem is with the function itself. In order for it to work you need to use the "this" keyword: class A { var $xxx; function print() { echo $this->xxx; } } You may also run into problems with calling the function print(), I don't know for sure. But the problem is that you were telling PHP to print a variable that was, technically, not even initialized. Mike Frazer "Olexandr Vynnychenko" <supaboy@i.com.ua> wrote in message news:3742964339.20011025213639@i.com.ua... > Hello php-general, > > I have such code: > > class A > { > var $xxx; > > function print() > { > echo $xxx; > } > } > > And that's what I get: > "Parse error: parse error, expecting `T_STRING' in xxx.php on line nn" > > Php doesn't let any function or class member have a name which is > already "used" by another function (or only function from library), > am I right? Or maybe "print" has special status. Maybe that's > because print() is actually not a function? Can anyone tell me > something about that, please? > > -- > Best regards, > Olexandr Vynnychenko > mailto:supaboy@i.com.ua > >

« previous php.general (#72326) next »