Strange code (Green) coming back from the database

Asked

Viewed 112 times

1

I have the following PHP query

$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);

$mysqli-> set_charset("utf8");

$stmt = $mysqli->prepare("select header, title, footer, head from configs");

$stmt -> execute();

$stmt -> bind_result($header, $title, $footer, $head);

$stmt -> fetch();

echo $header;

But when will I give the echo in the $header the code <?=$teste?> that is in the database comes as an exclamation and two tracts before the interrogation, causing the code does not appear, inspecting I can see that the variable is in green. Why?

2 answers

1

If you run only the code you have informed us, you will notice that this "green code" (which is a commented PHP code in the middle of your HTML, will not appear.

I recommend you to open the source code of this page that is running and look for "" and you will find that at some point you commented on this excerpt and forgot!

0

Color doesn’t matter, it’s just Highlight for tagging as PHP does.
I recommend you change <?=$teste?> for <?php echo $teste; ?>

You can see in the link http://php.net/ini.core#ini.short-open-tag, short tags are not always enabled.

  • As the documentation itself says, starting with PHP 5.4 you can use <?= without fear of being happy, because this configuration directive does not affect you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.