473,513 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reference or a Copy?

xu
Hi, i'm quite new with PHP.

I was wondering if i get a reference or a copy back when i try to
retrieve it at page2.php $foobar = $_SESSION['myobject'];

// page1.php

....
$myobject = new MyObject();
$_SESSION['myobject'] = $myobject;
....

// page2.php

....
$foobar = $_SESSION['myobject'];
....
Jul 17 '05 #1
2 1787
That would appear to make a copy.

At the end of page2.php, you could have $_SESSION['myobject']=$foobar;
to copy it back. Or you could use $_SESSION['myobject'] in place of
every $foobar and it should work the same.
xu wrote:
Hi, i'm quite new with PHP.

I was wondering if i get a reference or a copy back when i try to
retrieve it at page2.php $foobar = $_SESSION['myobject'];

// page1.php

....
$myobject = new MyObject();
$_SESSION['myobject'] = $myobject;
....

// page2.php

....
$foobar = $_SESSION['myobject'];
....

Jul 17 '05 #2
Thanks for your reply, it helped me alot with my insight of when php's
object reference is in place and when not.

I'm now going to test the & to see if i'm getting a reference or not.

// page2.php

....
$foobar =& $_SESSION['myobject']; ?
....

neur0maniak wrote:
That would appear to make a copy.

At the end of page2.php, you could have $_SESSION['myobject']=$foobar;
to copy it back. Or you could use $_SESSION['myobject'] in place of
every $foobar and it should work the same.
xu wrote:
Hi, i'm quite new with PHP.

I was wondering if i get a reference or a copy back when i try to
retrieve it at page2.php $foobar = $_SESSION['myobject'];

// page1.php

....
$myobject = new MyObject();
$_SESSION['myobject'] = $myobject;
....

// page2.php

....
$foobar = $_SESSION['myobject'];
....

Jul 17 '05 #3

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

Similar topics

36
28052
by: Riccardo Rossi | last post by:
Hi all! How does Python pass arguments to a function? By value or by reference? Thanks, Riccardo Rossi.
6
1701
by: JKop | last post by:
unsigned int CheesePlain(void) { unsigned int const chalk = 42; return chalk; } unsigned int& CheeseRef(void) {
10
2251
by: Tony Johansson | last post by:
Hello Experts!! This class template and main works perfectly fine. I have this class template called Handle that has a pointer declared as T* body; As you can see I have a reference counter in...
6
1456
by: WayneD | last post by:
Hi All, Just got started in C#... Here's some C# code: public MyClass { private MyThingy m_Thingy;
14
2392
by: key9 | last post by:
Hi All On coding , I think I need some basic help about how to write member function . I've readed the FAQ, but I am still confuse about it when coding(reference / pointer /instance) , so I...
8
2383
by: toton | last post by:
HI, One more small doubt from today's mail. I have certain function which returns a pointer (sometimes a const pointer from a const member function). And certain member function needs reference...
10
3410
by: JurgenvonOerthel | last post by:
Consider the classes Base, Derived1 and Derived2. Both Derived1 and Derived2 derive publicly from Base. Given a 'const Base &input' I want to initialize a 'const Derived1 &output'. If the...
10
13609
by: Robert Dailey | last post by:
Hi, I noticed in Python all function parameters seem to be passed by reference. This means that when I modify the value of a variable of a function, the value of the variable externally from the...
7
6652
by: pauldepstein | last post by:
#include <iostream> using namespace std; double & GetWeeklyHours() { double h = 46.50; double &hours = h; return hours; }...
275
12039
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
7257
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
7379
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,...
0
7535
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...
1
7098
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
7521
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...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.