473,396 Members | 1,724 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,396 software developers and data experts.

Indirect object access in php4

class A {
function Get() {return $this;}
}
$obj = new A();
In php5, the following statement is valid:
$x = $obj->Get()->Get();

In php4, I get the following error:
parse error, unexpected T_OBJECT_OPERATOR

I know I can do this:
$x = $obj->Get();
$y = $x->Get();

but I'd rather not. Is there a simple, one-line way to do indirect
object references in php4?

And yes, I know my example is silly. My real problem is for more
complicated cases, where multiple classes are involved.

Feb 8 '06 #1
2 1713
On 8 Feb 2006 10:54:40 -0800, "Zioth" <go****@zioth.com> wrote:
class A {
function Get() {return $this;}
}
$obj = new A();
In php5, the following statement is valid:
$x = $obj->Get()->Get();

In php4, I get the following error:
parse error, unexpected T_OBJECT_OPERATOR

I know I can do this:
$x = $obj->Get();
$y = $x->Get();

but I'd rather not. Is there a simple, one-line way to do indirect
object references in php4?


Nope, AFAIK. You have to go to PHP5.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Feb 8 '06 #2
> >but I'd rather not. Is there a simple, one-line way to do indirect
object references in php4?


Nope, AFAIK. You have to go to PHP5.


Not even some wierd trick, using typecasting and some form of brackets?
In perl, there are always ways to get around this kind of problem using
curly braces and typecasting.

What a strange thing for them to omit from PHP4. It seems like a pretty
basic thing for a parser to allow return values to be actionable. Oh
well.

Feb 9 '06 #3

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

Similar topics

2
by: Chung Leong | last post by:
Help me here. I've become a bitconfused about how PHP4 deals with objects after reading this description of PHP5: "PHP's handling of objects has been completely rewritten, allowing for better...
12
by: Berislav Lopac | last post by:
Is there a way for an object to unset itself in PHP4? Of course I could unset it from outside, but I would like to keep the code clean. The object has a method which deletes it's "footprint" in...
3
by: Hal Vaughan | last post by:
I'm not sure what the correct name for this would be. I'd think it's either an indirect reference, or a pointer, or something like that. I'm working on a program that would call a series of...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
2
by: Christopher Burns | last post by:
Hi all, We are using VB.NET (VS2K3), sitting on VSS6. I have sorted out a configuration problem that was preventing us from building from scratch for new developers, but now I am having a very...
13
by: ganeshb | last post by:
Hi, What C statement(s) would translate to indirect jmp in assembly? I know that function pointer invocation would translate to indirect 'call' instruction, but I am not sure what will lead to...
3
by: danish | last post by:
Hi, Can anyone tell me how to access oracle from php. Im using CentOS 4 with php4 already installed. From what I found after a bit of googling...php will have to be recompiled with oracle...
21
by: phpCodeHead | last post by:
Code which should allow my constructor to accept arguments: <?php class Person { function __construct($name) { $this->name = $name; } function getName()
5
by: Rahul B | last post by:
Hi, I am having the following issues while trying to restrict the current user from creating any objects. Below is the privileges for the user and response when i try to create a table in that...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.