Jump to content

[SOLVED] Formating HTML with htmlspecialchars


___ROCK___

Recommended Posts

<?php
$my_html = htmlspecialchars("<html> <head> <title> </title> </head><body>whats up	</body></html>");


echo $my_html;

?>

 

How can I format  this code so it appears like this

 

<html>

<head>

        <title> </title>

</head>

 

<body>whats up </body>

 

</html>

Can you guys show me a small example of what you mean on the above answers.  Maybe I'm not doing it right.

 

<?php
$my_str = htmlspecialchars('<html> <head> </head </html>' );
      
        echo $my_str;

?>

 

how can I format that above code to look like this.

 

<html>

 

<title> </title>

 

</html>

 

seriously? 

 

"simply add \n after each tag"

 

 

<html>\n<head>\n</head>\n</html>\n etc...

I did that but it did not work, and  since you are  a php guru show me something that works.

 

would you like me to hold your dick for you while you pee, too?

 

I don't you to hold my dick, Just open your mouth so I can pee and shit in it!

Our childish behavior has set me off track for a bit.  Now back to the main topic, I did not mention that I wanted see the formatted text.  :'(

 

Therefore what you have posted is correct, :o  but i need to go one step further which is display the formatted code.   

 

So if i wanted to say "u r rite oh great one".  i would like to have it displayed like this.

 

<html>
<title> The Grate One</title> 
<body> <p> You Are Right, Oh  Great One! </p></body>
</html>

Thanks for all the php help, and for helping me relieve  myself.  :D

 

 

 

 

 

Try str_replace:

 

 

<?php

$my_str = "<html>\n<title> The Grate One</title>\n<body>\n <p> u r Right, Oh  Great One! </p>\n</body>\n</html>";
      
$my_str  = str_replace('u', 'You', $my_str);
$my_str  = str_replace('r', 'Are', $my_str);

highlight_string($my_str);

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.