Jump to content

problem displaying php/html code


flunn

Recommended Posts

Greetings:

I'm trying to use htmlentities() to display html/php code on a web page. It works fine except for one problem: the code is displayed as a single line, but I want line breaks where I have put them in my editor.

Any advice as to how to solve this problem would be much appreciated.

 

regards to all

 

from flunn

Link to comment
https://forums.phpfreaks.com/topic/98497-problem-displaying-phphtml-code/
Share on other sites

New lines \n or \r\n are not html. To get them to result in html newlines, either wrap the code you want to display in < pre > .... < /pre > tags (without the spaces inside the tags) or use the php nl2br() function to insert html newlines.

Thanks to Steve Angelis and PFMaBiSmAd for their replies. I've tried the "<pre>" and the nl2br() ideas, but without success I'm afraid. 

 

I've also tried a couple of online translators that are supposed to make code friendly for display. They solve part of the problem but if I put in all the code I want to display they generate php errors like ("expecting T_string")

 

I'm afraid I've got in over my head here. Anyway thanks again to both of you and

 

regards to all from

 

flunn

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.