a interesting direction about Class in PHP.
| From: | Adam Bear | Date: | Mon, 18 Dec 2000 16:16:50 +0000 |
| Subject: | a interesting direction about Class in PHP. | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-4524@lists.php.net to get a copy of this message | ||
Maybe I should not post this message in PHP-windowss list, but
I only work on windows and only subscribed this list.so it would
be appreciated if some one repost this message in other list.
Today,when I run the test sample in source code of PHP,I found
a interesting direction to use class method, see the following code:
<? class foo {
var $hahaha;
function foo() {
print "I am foo\n";
}
function bar() {
print "Hey there!\n";
}
};
class foo2 extends foo{
function foo2(){
print "Het I am in foo2\n";
}
}
foo::bar() //haha, can't image we can use "::" operator in PHP!
foo2::bar() //even in a descended class can call his father's method.
?>
This is really true, all code above is tested by me in PHP4.04b and PHP4.0.1,
I think it can work in versions above PHP4.
This direction more like the static method calls in C++,it is very useful in
OO program,we can use a class method directly without create a object instance of
the class.
I search through the documents of PHP but can't find a word about this operator,
maybe PHP developer term think this operator useless in PHP or maybe this is a future
feature which will be full supported in the next version of PHP.
I am a chinese so sorry for my pool english. Enjoy youself.
Sincerely
Adam Bear
&&&&&&&&&&&&
\~~~~~~~~/
( $ $ )
{ "" }
=======================oOOo----()-----oOOo========
Wow.... Gold is there!
+-----------------------------------------------+
| My E-Mail ====> xcbear@netease.com
or bbbbear@china.com
+----------------------------------Oooo-----------+
oooO ( )
( ) ) /
\ ( (_/
\_)