Solved

PHP HTT_*VARS variables

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This article discusses four methods for overlaying images in a container on a web page
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

803 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