You are here: Manipulating an object returned from function « PHP Programming Language « IT news, forums, messages
Manipulating an object returned from function

Posted by Ryan Govostes on 07/13/07 16:11

Consider this cde:

/**********
class testClass {
var $value = 6;
}

function &getInstance() {
static $instance;

if(!isset($instance)) {
$instance = new testClass;
}

return $instance;
}

echo getInstance()->value;
/**********/

In PHP5, this correctly echos '6'. However, in PHP4, I get

Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ','
or ';' in /test.php on line 16

I do need to the code in this format, without splitting it into two
lines (which I know works). It would be detrimental to my project if
it turns out this won't work at all :-\

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация