php coding question

Chimpie

Well-known member
Let's say I'm coding a simple php page non-xenforo). As part of this page I want to write, "To code this, it should look like ..." where I would display that code. What would I wrap the code in so that it does execute?
 
I don't know PHP but couldn't you just use a string (echo).
If you just echo a string containing html it will output and be recognized as html.


Let's say I'm coding a simple php page non-xenforo). As part of this page I want to write, "To code this, it should look like ..." where I would display that code. What would I wrap the code in so that it does execute?
You just need to encode the html entities, here is an example of how to do that
PHP:
$exampleCode = '<div>example html here</div>';
echo 'To code this, it should look like ...' . htmlentities($exampleCode);

the output said:
To code this, it should look like ...&lt;div&gt;example html here&lt;/div&gt;
 
Top Bottom