Jump to content
Pardon our ads (a necessary update) ×

api; echo result-> browser interpretes html tags problem


Jeisson

Recommended Posts

Hello

 

i GET with api Json, The browser interpretes the html tags in the Json, so linting is not possible. i' assume the decoding is not affected?

//here I define the base url first, then

 

$url = $base_url;
$results = file_get_contents($url);
echo $results;
exit;
//Problem is that the browser interprete the html tags inside the Json. So I cannot lint the  result.

Q. How do i echo tags as text only in this case?

 

Anyway if I

$json_results = json_decode($results,true);

 

Will that be in its order and clean? how can I Lint that result?

the json is "body" : "<p></p>";

but I get echoed:

"body" : "

 

";

 

I think htmlspecialchars would change < to &lt, right?

Yes. Then you'd be able to see the HTML on your screen.

 

The other way is to write the response to a file, and then you'd have the raw response body.

 

$results = file_get_contents($url);
file_put_contents('response.txt', $results);

Anyway the decode dont get confused of html tags, is it so?

json_decode() does not care about HTML.

Archived

This topic is now archived and is closed to further replies.



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.