Forum Moderators: coopster
On my old PHP 4 server, when I have a filename "joe.php" with the contents:
<? function joe($poo) {
echo $poo;} ?>
<? joe($poo);?>
If I go to [mysitephp4.com...]
I see a page with "5" printed on it.
ON my New PHP5 server, the same [myphp5site.com...]
yields nothing.
Is there a new way to pass variables in PHP5?
How do I fix my script?
THANKS
register_globalsmust be set to On (probably in php.ini). However, this is a bit of a security hole and is better Off (in fact it should be Off).
Parameters passed in the URL can be accessed from the $_GET[] array, so you can modify your code to read:
<?php joe($_GET["poo"]); ?>
EDIT: register_globals [uk2.php.net] is available in PHP4 and 5 - it is a configuration setting. But has been removed from PHP6 apparently.
$Jim=$_GET["Jim"];
Yes, that's OK. (Is there any kind of potential security issue with using the same variable name?)
It might be an idea to check that $_GET["Jim"] is actually set first (if 'Jim' has actually been passed in the URL) as you could get a warning (E_NOTICE) depending on how error_reporting() is set, and simply just good practice.
$Jim = isset($_GET["Jim"]) ? $_GET["Jim"] : null;
(Or any default value you require in place of null)