php4 - Code not working in PHP 4 -


i have php script works fine in php 5, not in php 4. i've made small test case demonstrate (disclaimer: know below code written better, it's not used piece, rather 1 demonstrate i'm talking about):

class messenger {     var $messages = '';      function add($message) {         $this->messages .= "$message\n";     } }  function add($m) {     if (! isset($globals['instance'])) $globals['instance'] = new messenger();     call_user_func_array(array($globals['instance'], 'add'), array($m)); }  add("one"); add("two"); add("three");  var_dump($globals['instance']->messages); 

under php 5 messages property contains 3 messages, under php 4 empty. why?

in php 4, $this not seems work same way php 5 does.

the $this pseudo-variable not defined if method in hosted called statically. not, however, strict rule: $this defined if method called statically within object. in case, value of $this of calling object. illustrated in following example:

example : http://www.php.net/manual/en/keyword.class.php


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -