PHP $_GET is removing the + sign in a phone number in the URL. I suspect it is converting to a number rather than a string, but I haven’t figure out how to get around it.
The URL looks like:
[CODE]http://MyServer/quick_select.php?select=org&action=and&org=CompanyName&last=Jones&phone=%2B52%209999999999&email=myemail%40mydomain.com
The relevant php lines look like:
[CODE]$strQURL = $_SERVER[‘QUERY_STRING’];
echo $strQURL.”<br><br>”;
$phone=$_GET[“phone”];
echo “‘”.$phone.”‘<br><br>”;
echo “‘”.urldecode($phone).”‘<br><br>”;
echo “‘”.urlencode($phone).”‘<br><br>”;
The output looks like:
[CODE]org=CompanyName&last=Jones&phone=+52%209999999999&[email protected]&select=org&count=10&sid=0.9767910006196713
‘ 52 9999999999’
‘ 52 9999999999’
‘+52+9999999999’
As you can see:
– The complete URL is decoded properly as a whole with the %2B converted to a plus sign
– The $_GET[‘phone’] changes the + to white space
– urldecode() does not change the behavior.
– urlencode() puts an extra plus sign at the gap between the country code and area code.
I tried casting to a (string) – no change.
I need to handle the plus sign to recognize international phone numbers, but I don’t want to parse the query string myself.
Any suggestions?
Thanks
Phil