[nycphp-talk] PHP Undocumented Functionality...
Flavio daCosta
nyphp at n0p.net
Tue May 31 11:28:31 EDT 2005
Reading some interesting articles on http://phppatterns.com/ I came
across the following some code that has me scratching my head...
Can anyone explain why the code below works!? (in php4 and php5) And is
this simply an undocumented _side effect_, or is it intentional (from
the php developers)?
1) Per the php manual, you can't use $this in static functions.
2) How is the SomeClass property $errorMsg accessed within the Debug class?
Example code from
<http://www.phppatterns.com/index.php/article/articleview/15/1/1/>
<?php
class Debug {
function display () {
echo ($this->errorMsg);
}
}
class SomeClass {
var $errorMsg='This is an error message';
function someFunction () {
if ( DEBUG == 1 ) {
Debug::display();
}
}
}
define ('DEBUG',1);
$someClass= &new SomeClass;
$someClass->someFunction(); // Outputs: "This is an error message"
?>
Thanks,
Flavio
More information about the talk
mailing list