Php-Code to view Code

Discuss coding issues, and scripts related to PHP and MySQL.
User avatar
JanMolendijk
Posts: 169
Location: Holland Rotterdam

Php-Code to view Code

Dear admin hope you do okey ???

I looking for php code like I can do here with [ code] option
to show it on my website ???? so i`m also able to see <>

Admin
Hello,
I didn't understand your question.
What do you want to do?
What to show and what to see?

JanMolendijk
Sorry for my bad english

In my documents I want to see the full code in text
like I can do here for example

Code: Select all

<iframe src="http://145.53.93.209/Comments" 
width="300" height="440" frameborder="0" scrolling="yes" 
align="top" marginwidth="0" marginheight="0" name="offtopic">
</iframe>

Admin
Try to apply the htmlentities() function to the string with code in your php script that displays the page.
Example:

Code: Select all

$str ='Have a <b>Good life</b> with everyone and <em>with yourself</em>.';

echo htmlentities($str, ENT_QUOTES);

JanMolendijk
Thanks for the support but I could not make it work
after I made a search & found on php . net something

But I can not find out how to place enters in the document
the whole code shows without enter (for new row)

Code: Select all

<?php
$new = htmlspecialchars('<iframe src="http://145.53.93.209/Address.php" 

width="300" height="440" frameborder="0"

scrolling="yes" align="top" marginwidth="0"

marginheight="0" name="offtopic"></iframe>', ENT_QUOTES);

echo $new; 
?>

Admin
To replace the new line characters (\n,\r\n) with html <br> tag, use the nl2br() function.

Code: Select all

<?php
$str ='<iframe src="http://145.53.93.209/Address.php" 
width="300" height="440" frameborder="0"
scrolling="yes" align="top" marginwidth="0"
marginheight="0" name="offtopic"></iframe>';
$new = htmlspecialchars($str, ENT_QUOTES);
$new = nl2br($new, false);

echo $new; 
?>

JanMolendijk
Thanks Chief

You told me once that you do not judge,
but sometimes I wonder what you think
of my knowledge :D ????

Similar Topics