Amine Amine - 1 year ago 157
PHP Question

using html tags inside echo plus calling data from a db

I want to know why this works:

echo "<p><b> Num : </b> $vrac[isbn] </p>";

and not this:

echo "<p><b> Num : </b> htmlentities($vrac[isbn],ENT_QUOTES,'UTF-8') </p>";

What I'm trying to do is print data from a table in my db using htmlentities so special characters can be converted to html characters(avoiding the ? replacment).

P.S: The first code will print the data correctly, while the second code will print the data inside htmlentities(DATAHERE,ENT_QUOTES,'UTF-8') as it is written.

Answer Source

It does not work, because you cant call functions inside string. Following is how you do it:

echo "<p><b> Num : </b> " . htmlentities($vrac['isbn'],ENT_QUOTES,'UTF-8') . " </p>";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download