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

Object in array turns into reference when I access it.


Can anyone explain this? I'm running PHP Version 4.3.7

<?php
class foo {
function bar() {
}
}

$array["foo"] = new foo();

var_dump($array);
// Returns:
// array(1) {
// ["foo"]=>
// object(foo)(0) {
// }
// }

$array["foo"]->bar();

var_dump($array);
// Returns
// array(1) {
// ["foo"]=>
// &object(foo)(0) { <-- How did that happen?
// }
// }
?>
--

__o Alex Farran - PHP / MySQL Web application development
_`\<,_ site: www.alexfarran.com phone: 01273 474065
(_)/ (_) blog: alexfarran.blogspot.com mobile: 07790 389330
Jul 17 '05 #1
4 1464
Alex Farran wrote:
Can anyone explain this? I'm running PHP Version 4.3.7


See: http://bugs.php.net/bug.php?id=11543
JW

Jul 17 '05 #2
Janwillem Borleffs writes:
Alex Farran wrote:
Can anyone explain this? I'm running PHP Version 4.3.7
See: http://bugs.php.net/bug.php?id=11543


Thank you. So it is a bug. The last comment talks about the
__clone() method in Zend 2, which seems slightly tangential to the
problem. Can someone with PHP5 installed run my script and show me
what happens?

--

__o Alex Farran - PHP / MySQL Web application development
_`\<,_ site: www.alexfarran.com phone: 01273 474065
(_)/ (_) blog: alexfarran.blogspot.com mobile: 07790 389330
Jul 17 '05 #3
Alex Farran wrote:
Can someone with PHP5 installed run my script and show me
what happens?


Yes:

array(1) {
["foo"]=>
object(foo)#1 (0) {
}
}
array(1) {
["foo"]=>
object(foo)#1 (0) {
}
}

HTH,

PS: I used the script you gave in the first post, if you need me to test
another, i'd love to help.

Best regards,
Sebastian
Jul 17 '05 #4
Sebastian Lauwers writes:
Alex Farran wrote:
Can someone with PHP5 installed run my script and show me
what happens?
Yes:


Thanks. That's much more sensible behaviour. One more reason to
switch to PHP5 ASAP.

--

__o Alex Farran - PHP / MySQL Web application development
_`\<,_ site: www.alexfarran.com phone: 01273 474065
(_)/ (_) blog: alexfarran.blogspot.com mobile: 07790 389330
Jul 17 '05 #5

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

Similar topics

6
by: lawrence | last post by:
How dangerous or stupid is it for an object to have a reference to the object which contains it? If I have a class called $controllerForAll which has an arrray of all the objects that exist, what...
5
by: simon place | last post by:
is the code below meant to produce rubbish?, i had expected an exception. f=file('readme.txt','w') f.write(' ') f.read() ( PythonWin 2.3 (#46, Jul 29 2003, 18:54:32) on win32. ) I got...
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()',...
38
by: VK | last post by:
Hello, In my object I have getDirectory() method which returns 2-dimentional array (or an imitation of 2-dimentional array using two JavaScript objects with auto-handled length property - please...
5
by: Michael Moreno | last post by:
Hello, In a class I have this code: public object Obj; If Obj is a COM object I would like to call in the Dispose() method the following code: ...
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
8
by: sexauthor | last post by:
I'm converting a VB6 application over that called a 3rd party DLL with specific data structures. The VB6 code defined custom types for those data structures (ie: one with the specific data types,...
1
by: BiraRai | last post by:
is it possible to add new variable to a array object at run time? the following code does not work. $iterator->current()-> = 1234; how can this be done? function...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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...

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.