Amine Amine - 7 months ago 71
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.


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>";