Say, $var = "Hello<br>How are <strong>you</strong>";
I want echo $var
to display the assigned string Hello<br>How are <strong>you</strong>
as it is not the parsed html code.
How do I do that?
HTML tags will automatically parsed by the browser. To see the pure HTML source anyways, the tags needs to be encoded, especially the angle brackets.
There is a dedicated PHP function available for that called htmlentities() .
$var = "Hello<br>How are <strong>you</strong>";
echo htmlentitites($var);
Will encode it in the browser so you can see it displayed as plain text like in $var
. The browser will see this:
Hello<br>How are <strong>you</strong>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.