Re: strtr array replace issue...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Mon, 9 Feb 2009, Brad Freshour wrote:

To: php-install@xxxxxxxxxxxxx
From: Brad Freshour <bfreshour@xxxxxxxxx>
Subject:  strtr array replace issue...

Apache: 2.2.8 threaded
PHP: 5.2.4-2
mySQL: 5.051.a

Ubuntu 8.04 minimal with everything needed installed via apt-get.

Using SMF forum, I'm having an issue with the strtr command...  Here's
the code...

$ftp_file = strtr($filename, array ($_SESSION['pack_ftp']['root'] =>''));

The $_SESSION['pack_ftp']['root'] variable is an empty set: ''

Well, if the above strtr command was translated it would look like this:

strtr("/home/user/public_html/Packages/temp", array ('' =>''));

You would think that the return would be : /home/user/public_html/Packages/temp

However, it returns '' instead.

I can get around this by modifying the code to the site manually and
checking to see if $_SESSION['pack_ftp']['root'] == '' and if it does
assign it something crazy, like $_SESSION['pack_ftp']['root'] =
'%%%%%'

However, the code works on another site I have that's hosted for me
(shared hosting).

Anyone have any ideas?

I was wondering if it was related to this: http://bugs.php.net/bug.php?id=27457
But that seems like an old bug...

Thanks.

You can run php as a 'BASIC-style' command-line interpreter and debug awkward code like this one line at a time.

Just do:

[root@localhost keith]# php -a
Interactive shell

php > $a= "hello";
php > echo $a;
hello
php >

All the php functions are available in interactive mode.
That way you get immediate feedback on how your code works :)

Kind Regards,

Keith

-----------------------------------------------------------------
Websites:
http://www.php-debuggers.net
http://www.karsites.net
http://www.raised-from-the-dead.org.uk

All email addresses are challenge-response protected with
TMDA [http://tmda.net]
-----------------------------------------------------------------

[Index of Archives]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [Postgresql]     [PHP Books]     [PHP Databases]     [PHP SOAP]
  Powered by Linux