Solved

PHP HTT_*VARS variables

Posted on 2012-03-16
4
268 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 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
 
LVL 1

Author Comment

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

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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

626 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