473,404 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Manipulating an object returned from function

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 :-\

Jul 13 '07 #1
1 1242
..oO(Ryan Govostes)
>Consider this cde:
[...]

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
PHP 4 doesn't support this syntax.
>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 :-\
If you really want to use OOP and its features, then drop PHP 4 and use
PHP 5.

PHP 4 is reaching its end of life this year (see <http://www.php.net/>),
while PHP 6 is going to see the light of day in maybe a few months.

Micha
Jul 13 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
4
by: SP | last post by:
Hi I have a problem with a customer's XML being submitting to me in a non-well-format XML. They said that there are 18 other partners who has been able to tweak the XML to make it work. So I...
100
by: E. Robert Tisdale | last post by:
What is an object? Where did this term come from? Does it have any relation to the objects in "object oriented programming"?
8
by: ST | last post by:
Hello everyone, Can anyone help me with this error above when I debug my web app project in vstudio.net?? I can't figure it out! It was working fine for months, and now all of a sudden it's not!!...
4
by: gg9h0st | last post by:
i worte a simple code below. ------------------------------------------------------------------------------------ #include "stdafx.h" class Object { public: int a;
5
by: NC AQUA | last post by:
Evening everyone... First, this is a homework assignment and I am not looking for the direct answer (notice no code...), but instead I need direction to help figure this out. I am new to this and...
1
by: Stephen Cattaneo | last post by:
Hi all, I am relatively new to socket programming. I am attempting to use raw sockets to spoof my IP address. From what I can tell I will have to build from the Ethernet layer on up. This is...
1
by: Paul Childs | last post by:
Hi folks, I'll start off with the code I wrote... (ActivePython 2.4 on Windows XP SP2) ------------------------------- class FlightCondition(object): lsf = vto =
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.