Solved

PHP HTT_*VARS variables

Posted on 2012-03-16
4
261 Views
Last Modified: 2012-04-23
Hi,
I'm fixing some old code.
Through the code I'm seeing the following vars set as global

$HTTP_POST_VARS     (Changing to $_POST)
$HTTP_GET_VARS       (Changing to $_GET)
$HTTP_COOKIE_VARS   (Changing to $_COOKIE)
$HTTP_SESSION_VARS  (Changing to $_SESSION)      
$HTTP_POST_FILES  (Change  to  what??)

Questions

1. Once I enabled register_long_arrays in php.ini my code began working. I'm guessing this isn't the best solution though. So I want to change all of my HTTP vars to their newer version. Are all of my "Changes" above correct?

2. What do I change HTTP_POST_FILES? Is this considered one of the "register_long_arrays"?

3. From what I've been reading in the docs, changing the HTTP vars above will be fine and they will all return the same data they once did.  Does anyone see a problem with changing any of these? I don't want to introduce another problem.

Thanks
Nacht
0
Comment
Question by:nachtmsk
4 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 37731955
$_FILES is the other one.  They are all listed here: http://www.php.net/manual/en/reserved.variables.php
0
 
LVL 17

Expert Comment

by:nanharbison
ID: 37732395
What version of PHP are you using? Are you upgrading that as well?
0
 

Author Comment

by:nachtmsk
ID: 37732474
PHP V 5.3.3 I believe.
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 37732518
I do not see a problem with changing these, however they may not be the only things that need to be changed, so you might consider grabbing a copy of subVersion or a similar change control system.

PHP has migration guides that may be helpful.  You might want to run phpinfo() on the old system to know what version you are coming from, then start looking through the links here.
http://php.net/manual/en/migration5.php

There are two directives that commonly cause troubles when they are changed; these may trip you up.  They are described in these articles.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_6630-Magic-Quotes-a-bad-idea-from-day-one.html
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_7317-Register-Globals-a-bad-idea-from-day-one.html

You may find the use of ereg() functions which are now deprecated and will be removed.  These need to be converted to preg() function patterns.  For the most part, this is as easy as adding regex delimiters and the "i" at the end for case-insensitivity.

You can learn a lot by (temporarily) adding this to the top of your scripts:

error_reporting(E_ALL);

That may cause a lot of Notice messages because PHP will issue a Notice when an undefined variable is used.  By default the PHP error reporting does not display Notices so your scripts may be using the undefined variables as if they are FALSE, NULL, zero, etc.  While this could be called "sloppy programming" it is not a practice that requires remediation during the upgrade.

HTH, and good luck! ~Ray
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now