PHP has issues... what's the cure?

Kazuma

New member
I'm simply trying to test a javascript which I call with the following code:
var url = "test.php?json=" + encodeURI(t.toJSONString()); //think of t.toJSONString() as a normal string

Then on the PHP side which AJAX calls with that url variable I have the following three line program:
<?php
echo $_GET['json'];
?>

An example of what is being sent to PHP:
http://site/test.php?json=%7B%22fname%22:%22Yahoo%22,%22lname%22:%22Kazuma%22%7D


When accessing this PHP page it results in the following 1line source code:
{\"fname\":\"Yahoo\",\"lname\":\"Kazuma\"}


What is it's problem? I encoded the url and sent the data to PHP. I've tried a variations of things so far. I tried: urldecode, trim for php and escape, encodeURI and encodeURIComponent for javascript

Really don't understand why PHP isn't removing those "\". It is causing problems with my javascript. I'm about to remove the "\" manually with regex in either PHP or Javascript but want to make sure there is no function in PHP which already exist for the task.
Thanks so much mmofangamer! It's working perfect now :)
 
Back
Top