Solved

PHP HTT_*VARS variables

Posted on 2012-03-16
4
266 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 83

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 109

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to create an extensible mechanism for linked drop downs.
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.

789 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