?
Solved

Break Copy By Reference

Posted on 2009-04-16
3
Medium Priority
?
276 Views
Last Modified: 2012-05-06
How do I create a copy of the original from a reference.

$A = 1;
$B =& $A;
$C = $B;

How do I ensure $C is not a reference to $A, but a copy of $A.
0
Comment
Question by:nbcit
3 Comments
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 1400 total points
ID: 24162358
You are allready doing that:
$A = 1;
$B =& $A;
$C = $B;
 
$A = 2;
echo $C;  # outputs '1'
 
###############
 
$A = 1;
$B =& $A;
$C =& $B;
 
$A = 2;
echo $C;  # outputs '2'

Open in new window

0
 
LVL 8

Assisted Solution

by:aldanch
aldanch earned 600 total points
ID: 24162366
Here is a good explanation of references... it may help answer your question.

http://blog.libssh2.org/index.php?/archives/51-Youre-being-lied-to..html
0
 

Author Comment

by:nbcit
ID: 24162706
You are right, I hadn't made a copy of it before using it. Thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month15 days, 12 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question