Comments By: Nitish Rathi
-
Sorry about the formatting. Can I submit formatted comments?posted on Aug 22, 2007 at 1:13pm | context
-
I can add a few more to the list of things you should dislike about PHP: Can't implement multiple interfaces which both declare the same functionposted on Aug 22, 2007 at 1:11pm | context
interface Runnable { function run(); } interface Task { function run(); } // won't work class Job implements Runnable, Task { function run() { echo 'run'; } }
Can't initialize a field by calling a function/methodclass Fields { private $array1 = array('f', 'o', 'o'); private $string1 = 'foo'; // the following lines just won't work private $foo1 = $this->createFoo(); private $foo2 = Fields::staticCreateFoo(); private function createFoo() { return 'foo'; } private static function staticCreateFoo() { return 'foo'; } }
Dynamic static method call doesn't work as expected// will create a new instance of ClassName; $name = "ClassName"; $instance = new $name(); // will run method(). public function method() { //some code } $methodName = "method"; $methodName(); // won't work class ClassName { public static function staticClassMethod() { //some code } }
$name = "ClassName"; $name::staticClassMethod(); T_PAAMAYIM_NEKUDOTAYIM Turns out it’s Hebrew for '::'. Thank you, PHP, for teaching me a Hebrew word.