I have this PHP code, which try to get the description of a YouTube channel, and run it in a JS file (xhr_object), and I've got this error : Unexpected token ILLEGAL. But I found the problem : $channel_descr contains a simple quote in somes cases, which break the JS code. I've already tried to use str_replace() but it doesn't change anything..
$json = file_get_contents("...?alt=json&part=snippet");
$data = json_decode($json, true);
$channel_descr = $data['entry']['content']['$t'];
$channel_descr = str_replace("\"", "‚", $channel_descr);
echo "alert (".$channel_descr.");";
Thanks.
EDIT
echo "alert ('".$channel_descr."');"; //Same Error