php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18013 Local variable losing value
Submitted: 2002-06-27 05:20 UTC Modified: 2002-06-28 09:19 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: miguel at ipatimup dot pt Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.2.1 OS: Linux 2.2.16 - Suse 7.x
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: miguel at ipatimup dot pt
New email:
PHP Version: OS:

 

 [2002-06-27 05:20 UTC] miguel at ipatimup dot pt
This is a big snip of the code:

$temp_file_path="/temp/x/1234.IMG.gz";
$interfile_final_path="/temp/1234.IMG.gz";

printf("<P>BEFORE:temp_file_path=%s<BR>interfile_final_path=%s</P>",                            $temp_file_path,$interfile_final_path   
                         ); 
$file_name = $interf->getFileName();               printf("<P>AFTER:temp_file_path=%s<BR>interfile_final_path=%s</P>",
$temp_file_path,$interfile_final_path ):

Object $interf, is a class created by me.
The method getFileName() of the class is implemented like this:   

function getFileName()
{
     $aux =  $this->_getFileName();
     //print "aux= $aux<BR>";
     $ret = basename( $aux, ".IMG.gz" );
     //print "ret=$ret<BR>";  
     return $ret;
}

My problem is that var $temp_file_path after a call to method getFileName, gets the value returned by getFileName
Is there any way of knowing the address( pointer like ) of a variable?

My configure line: 
'./configure' '--with-apxs=/usr/local/apache/bin/apxs' '--with-pgsql'
            '--with-oci8=/usr/local/oracle' '--with-oracle=/usr/local/oracle' '--with-debug'

Also, ftp functions are active.


If any adicional information is needed please let me know.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-27 05:52 UTC] sander@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php

Thank you for your interest in PHP.

There are no pointers in PHP, but in some cases references will do. 
 [2002-06-27 07:25 UTC] miguel at ipatimup dot pt
I, i'm sorry to upset you again....but i have some extra things to tell you about the bug:

The code seams to be right, doesnt it?
Please take a look at the explanations below.


 >$temp_file_path="/temp/x/1234.IMG.gz";
   >$interfile_final_path="/temp/1234.IMG.gz";

   >printf("<P>BEFORE:temp_file_path=%s<BR>interfile_final_path=%s</P>",    
   >                       $temp_file_path,$interfile_final_path   
   >                         ); 
   
   Output: BEFORE:temp_file_path=/temp/x/1234.IMG.gz<BR>interfile_final_path=/t
   
   >$file_name = $interf->getFileName();
   >printf("<P>AFTER:temp_file_path=%s<BR>interfile_final_path=%s</P>", $temp_f
   
   Output: AFTER:temp_file_path=/temp/x/1234<BR>interfile_final_path=/temp/1234

   After this line, var $temp_file_path has changed...reason????

   If i comment out the getFileName() line, the output is correct. 
   It seams that PHP is executing something like: $temp_file_name =
   $file_name after getFileName() method.
   
   Again, i'm very sorry if you dont think this a bug, but this anormal beaviour
isnt right. Dont you agree?

Regards
Miguel
 [2002-06-27 07:32 UTC] sander@php.net
Can you provide a _simple_ and _selfcontained_ sample script, say about 5 lines long, so we can play with it a little?
 [2002-06-27 07:55 UTC] miguel at ipatimup dot pt
I, here are the requested lines:

$temp_file_path = "/home/mnuc/x/1234.IMG.gz";    
$interfile_final_path = "/home/mnuc/1234.IMG.gz";
$full_file_path = $temp_file_path;
printf("<P>BEFORE:temp_file_path=%s<BR>interfile_final_path=%s</P>",
                           $temp_file_path,$interfile_final_path
                         );
$ficheiro_nome = basename( $full_file_path, ".IMG.gz");
printf("<P>AFTER: temp_file_path=%s<BR>interfile_final_path=%s</P>",
                           $temp_file_path,$interfile_final_path
                         );
die();

Regards,
Miguel
 [2002-06-27 11:51 UTC] rasmus@php.net
Your example code prints out:

BEFORE:temp_file_path=/home/mnuc/x/1234.IMG.gz
interfile_final_path=/home/mnuc/1234.IMG.gz
AFTER: temp_file_path=/home/mnuc/x/1234.IMG.gz
interfile_final_path=/home/mnuc/1234.IMG.gz

Looks right to me.
 [2002-06-27 12:46 UTC] miguel at ipatimup dot pt
I, 

>Your example code prints out:

>BEFORE:temp_file_path=/home/mnuc/x/1234.IMG.gz
>interfile_final_path=/home/mnuc/1234.IMG.gz
>AFTER: temp_file_path=/home/mnuc/x/1234.IMG.gz
>interfile_final_path=/home/mnuc/1234.IMG.gz

>Looks right to me.
How do you get the right output?
The output you have got is the right output.
On my PHP i got:

BEFORE:temp_file_path=/home/mnuc/x/1234.IMG.gz
interfile_final_path=/home/mnuc/1234.IMG.gz
AFTER: temp_file_path=/home/mnuc/x/1234
interfile_final_path=/home/mnuc/1234.IMG.gz

How can this be possible?

Does any one have any solution, tip?

Thank's
 [2002-06-27 18:45 UTC] sniper@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php

Thank you for your interest in PHP.


 [2002-06-27 19:00 UTC] rasmus@php.net
Are you sure you are using PHP 4.2.1?  There was a bug once upon a time where basename() corrupted the source string.  You could try upgrading to a newer version of PHP.
 [2002-06-28 06:23 UTC] miguel at ipatimup dot pt
I, sorry, but the fault was mine.
I have reported to have PHP 4.2.1, but i have PHP 4.1.2.

Thanks
 [2002-06-28 09:19 UTC] derick@php.net
user error -> bogus
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 10:01:29 2024 UTC