Avatar of nachtmsk
nachtmsk
Flag for United States of America asked on

PHP code and $_GET $_POST

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
PHPScripting Languages

Avatar of undefined
Last Comment
Terry Woods

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
gr8gonzo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Ray Paseur

str_split() may be your friend in some of these places.
Terry Woods

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.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck