php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2692 clarification: unset and reference
Submitted: 1999-11-10 13:05 UTC Modified: 2000-03-10 12:41 UTC
From: php-bug at vogtner dot de Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0 Beta 2 OS: any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php-bug at vogtner dot de
New email:
PHP Version: OS:

 

 [1999-11-10 13:05 UTC] php-bug at vogtner dot de
<%    
   function sub (&$v)
   {  
      unset ($v);
      $v = 66;
   }  
      
   sub ($s);
   echo '<br>$s = '. $s . "\n"; 
   echo '<br>isset ($s) = '. isset ($s) . "\n"; 
%> 

(a) unset breaks the reference between local $v
and parameter $s.

(b) $s becomes defined (no more warnings) by taking
a reference but it is not set.

Will this be documented?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-11-14 03:02 UTC] joey at cvs dot php dot net
${$v} should work for a dereference operator, right?
If you compare the output of the script below with that
of the original example above, you will see that "dereferencing"
unset($v) is no longer breaking the reference...

Moving to "Misbehaving function". unset() should not break
ref.


<?
  function sub (&$v)
 {  
unset (${$v});
 $v = 66;
 }  
                                      
 sub ($s);
 echo '<br>$s = '. $s . "\n"; 
 echo '<br>isset ($s) = '. isset ($s) . "\n";
?>
 [2000-03-10 12:41 UTC] andi at cvs dot php dot net
unset() within a function removes the variable from the functions symbol table. It doesn't actually nuke the outside variable. You could assign NULL to the variable.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 14:01:35 2025 UTC