Re[2]: [PHP] calling static method within class
| From: | Tom Rogers | Date: | Sat, 29 Oct 2005 04:32:00 +0000 |
| Subject: | Re[2]: [PHP] calling static method within class | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-224798@lists.php.net to get a copy of this message | ||
Hi,
Saturday, October 29, 2005, 5:42:15 AM, you wrote:
CR> If you're expecting the statement
CR> Echo Foo::getUs();
CR> To echo "me& me" it will not because you never returned $us from the
CR> getUs() method. I'm assuming also that xxx is a variable to mean "some
CR> class library" correct?
CR> Carlo Razzeto
CR> Programmer
CR> Mortgage Information Services
CR> Phone: (216) 514-1025 ex. 1212
CR> -----Original Message-----
CR> From: blackwater dev [mailto:blackwaterdev@gmail.com]
CR> Sent: Friday, October 28, 2005 1:13 PM
CR> To: php-general@lists.php.net
CR> Subject: [PHP] calling static method within class
CR> I have a class that won't be instantiated...so basically just a bunch
CR> of static methods.
CR> How do I call one of the class' static methods from within another
CR> method? Can't use this, and self doesn't work...this is php4.
CR> Thanks.
CR> Class Foo{
CR> function getMe(){
CR> return "me";
CR> }
CR> function getUs(){
CR> $us=xxx::getMe();
CR> $us.="& me";
CR> }
CR> }
CR> echo Foo::getUs();
Just use the class name Foo::getMe()
Class Foo{
function getMe(){
return "me";
}
function getUs(){
$us=Foo::getMe();
$us.="& me";
}
}
--
regards,
Tom