Reply to PHP 5 Strings are References?!

Your name:

Reply:


Posted by Richard Lynch on 03/30/05 06:18

Aha!

Okay, here's the previous session question boiled down to its simplest:

<?php
session_start();
if (!isset($_SESSION['name'])){
$_SESSION['name'] = 'Richard Lynch';
}
else{
$name = $_SESSION['name'];
}
/* Assume a ton of code goes here */
$name = 'Fooey';
echo "Session name is: ", $_SESSION['name'], "<br />\n";
?>

Now, hit this page, re-load it, and what do *YOU* expect $_SESSION['name']
to output?

A) 'Richard Lynch', because you never re-assigned $_SESSION['name']
B) 'Fooey' because $name is a reference, and you changed it, so that
changed your session data.

*I* expected A)
Alas, the reality is B)

Grrrrrrrr. I do *NOT* want all my strings to suddenly turn into pointers.
If I wanted that kind of headache, I'd be coding in C! :-)

I should have known this from the get-go, when I saw & in my session data
with var_dump($_SESSION); *WHY* are strings suddenly turning into
references? They're *NOT* objects!

I'm about to go re-read the PHP 5 sections of the manual with a fine-tooth
comb to see if I just missed this as an upgrade issue.

It's pretty much going to break a hell of a lot of scripts, that's for sure.

Somebody please tell me this is a Bug, not a "Feature"

PHP 5.0.3
FreeBSD 5.3-RELEASE

--
Like Music?
http://l-i-e.com/artists.htm

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация