php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5204 unset global arrays
Submitted: 2000-06-23 15:43 UTC Modified: 2000-06-24 02:12 UTC
From: eyvonne at esharp dot net Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0.0 Release OS: FreeBSD
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: eyvonne at esharp dot net
New email:
PHP Version: OS:

 

 [2000-06-23 15:43 UTC] eyvonne at esharp dot net
As previously reported in bug report # 1971..  

I am running the 4.0.0 release of PHP and can not access global variables outside of the function
when the arrays had been reset with unset().

Here's the function :

function get_images($lognum)  {
global $small_images, $large_images, $num_images;

$ls_command = "ls pics/logs/" . $lognum . "s*.jpg";
$image_name = "pics/logs/" . $lognum . "s.jpg";

if (file_exists($image_name))  {
  unset($small_images);
  exec($ls_command,$small_images);
  $ls_command = "ls pics/logs/" . $lognum . "l*.jpg";
  unset($large_images);
  exec($ls_command,$large_images);
  $num_images = count($small_images);
  }
else
  $num_images = -1;
}

Then when I do:
get_images($row["lognum"]);
print $small_images[0];

I get no values returned.  When I comment the unset lines everything works perfectly.

When I run a phpinfo(), here is some of the information that's provided:
FreeBSD my.systemname.com 4.0-RELEASE FreeBSD 4.0-RELEASE #0: Mon Mar
                                                     20 22:50:22 GMT 2000
                                      root@monster.cdrom.com:/usr/src/sys/compile/GENERIC i386

'./configure' '--prefix=/usr/local' 'i386--freebsd4.0' '--with-system-regex'
                                     '--with-apache=/usr/ports/www/apache13-php4/work/apache_1.3.12'
                                   '--with-config-file-path=/usr/local/etc' '--disable-debug' '--enable-track-vars'
                                      '--without-gd' '--disable-pear' '--with-zlib' '--with-mcrypt=/usr/local'
                                                 '--with-xml=/usr/local' '--enable-ftp'




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-06-24 02:12 UTC] stas at cvs dot php dot net
Do not try to unset "global" variable. Unset $GLOBALS["foo"].
Unsetting "global" does nothing useful.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 08:01:30 2025 UTC