php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7444 General reference problems
Submitted: 2000-10-24 19:37 UTC Modified: 2001-03-29 11:41 UTC
From: heathm at effinitylabs dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.0.3 OS: RedHat Linux 7.0/6.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: heathm at effinitylabs dot com
New email:
PHP Version: OS:

 

 [2000-10-24 19:37 UTC] heathm at effinitylabs dot com
We've been having lots of problems with references (especially storing references to objects in arrays).  We beleive we've narrowed a big part of our problems down to the following example.

<?php

// What's the difference between this...

function foo(&$b) {
  global $c;
  $c = &$b; // I don't want a COPY of the variable I want a REFERENCE
}

$a = "Start";
foo($a);
$c = "End";
echo $a; // Shouldn't this echo "End" not start?

// ... and this ...

$a = "Start";
$b = &$a;
$c = &$b;
$c = "End";
echo $a; // This echoes "End" as is expected

// The latter works just fine but the former doesn't.  Why not?
?>

I posted a similar example on the PHP mailing list only to be told PHP doesn't support C pointers.  What a nice piece of advice.  Too bad it doesn't apply here.

This introduces all kinds of problems especially when using objects and trying to create object container classes.

Thanks,

Mike Heath
EffinityLabs.com


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-24 22:33 UTC] heathm at effinitylabs dot com
Hahaha... just kidding.  I get it now.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC