0
What is the best way to save small PHP codes in the Mysql database, so that they could be viewed eventually, along with texts saved in HTML in the database?
0
What is the best way to save small PHP codes in the Mysql database, so that they could be viewed eventually, along with texts saved in HTML in the database?
2
If you want to convert these codes to use as an example in your application... Follow the tip.
Uses the function htmlentities
to encode PHP code. This function will convert all applicable characters into HTML entities, for example:
That code
<?php
$variable = ["A", "B", "C"];
var_export($variable);
?>
Will be transformed into:
<?php
$variable = ["A", "B", "C"];
var_export($variable);
?>
Once done, you can use in your HTML normally.
Meu código:
<pre>
<code>
<?php
$variable = ["A", "B", "C"];
var_export($variable);
?>
</code>
</pre>
To use this function, just do it as follows:
<?php
$str = "A 'quote' is <b>bold</b>";
// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str);
?>
Guys, now it’s clear how to display PHP code saved in bd. I’ll open another question addressing how to compile PHP code.
Browser other questions tagged php html
You are not signed in. Login or sign up in order to post.
Coding with
htmlentities
– Valdeir Psr
In case you want to compile the codes later ?
– Marcos Brinner
@Marcosbrinnerpikatoons think it will use including in the middle of the script, with some function, etc
– rbz