Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP4 > PHP5

Status
Not open for further replies.

DaveC426913

Programmer
Jul 28, 2003
274
CA
I have a PHP 4.2 app on a system that's running PHP5.

The big difference of course is the superglobals and the POST/GET variables. I've temporarily switched the security for these features off, so I can be sure my app is running. Now I've got to flip the switches back on.

I suppose, as far as the GET/POSTs, they're pretty easy to track down and change, but I need a reliable way of finding all the superglobals so I can declare them explicitly. Unless I'm mistaken it's impossible to tell local variables from superglobals.

Advice?

 
I don't understand what you mean when you say, "finding all the superglobals so I can declare them explicitly". Superglobals will exist whenever a form is submitted (for $_GET and $_POST) or session_start() is invoced (for $_SESSION) or cookies uses (for $_COOKIE) -- they don't have to be declared.

And you're right, there is no attribute that can differentiate between superglobals and regular arrays. But keep in mind there are a limited number of superglobal arrays:


Want the best answers? Ask the best questions! TANSTAAFL!
 
i guess you mean

"is there an easy way to tell when the code is relying on gpc variables being automatically/automagically registered rather than having to reference them explicitly". (e.g. $_POST['input'] is registered and can be referred to as $input)

answer "yes" (ish).

in the first line of every page set error reporting to E_ALL
Code:
error_reporting (E_ALL);

this will inform you of every variable that is not explicitly assigned when the script comes across it. it does not pick up the errors/notices at parse-time but as and when you use the specific script/function.

this level of error reporting (clearly) should not be used on a production box.
 
this will inform you of every variable that is not explicitly assigned when the script comes across it."

Thank you. I think that will do nicely.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top