?
Solved

PHP code and $_GET $_POST

Posted on 2012-03-16
3
Medium Priority
?
410 Views
Last Modified: 2012-06-21
Hi,
I've posted here before about someone elses (non-working) PHP code I am making my way through. The code was written about 2005, if that tells you anything about the version of PHP they were using.
After posting the code, one of your Experts noticed that this was defined in many places:
global $HTTP_GET_VARS
global $HTTP_POST_VARS
I have since changed every occurance of $HTTP_GET_VARS to $_GET and  $HTTP_POST_VARS to $_POST.  My code is still not working but I have made some progress and now it's 'kinda' working.

I have a few questions

1.  Does $_POST return the same data in the same way that $HTTP_POST_VARS would have returned? The same question applies to $_GET and $HTTP_GET_VARS.

2. I'm noticing the split function in used throughout the code. I've read that it's deprecated and not advisable to use. below is one example of the split.
My questions regarding this are
    -  online docs say I should use preg_split(). How would I rewrite this using preg_split
    - It looks from the code that's it's splitting on a colon, thing is that I don't see any way a colon could have gotten into the string that CCGetFromGet is returning. Does the colon exist in the array that $_GET returns? If so, I'm not seeing when I do a var_dump($_GET).
   
$CCSForm = split(":", CCGetFromGet("ccsForm", ""), 2);

//Here is the function it's calling
function CCGetFromGet($parameter_name, $default_value = "")
{

    //global $HTTP_GET_VARS;
//echo $_GET[$parameter_name];
return isset($_GET[$parameter_name]) ? CCStrip($_GET[$parameter_name]) :$default_value;
}
//End CCGetFromGet

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
3 Comments
 
LVL 35

Accepted Solution

by:
gr8gonzo earned 2000 total points
ID: 37729503
1. Yes.

2. If you're just splitting by a single character delimiter, then use explode() instead of split(). It has the same syntax, so it should just be a matter of changing the function called. If you want to split by a regular expression, then you would use preg_split.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 37731572
str_split() may be your friend in some of these places.
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 37734031
Note that in newer versions of PHP the split function is deprecated in favour of str_split and preg_split. Best not to add new code using split as it may need updating again later.
0

Featured Post

Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

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 i…
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 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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

800 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