Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PHP HTT_*VARS variables

Posted on 2012-03-16
4
Medium Priority
?
270 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 84

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
 
LVL 1

Author Comment

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

Accepted Solution

by:
Ray Paseur earned 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
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 …

670 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