The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Display PHP code
David B.
post Sep 19 2008, 03:34 PM
Post #1





Group: Members
Posts: 1
Joined: 19-September 08
Member No.: 6,703



I need to be able to display some PHP code on a page, without the code executing.
The code tag does not seem adequate.

Any advice on how this can be done?

Thanks,
David Berghouse
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Sep 19 2008, 04:08 PM
Post #2


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



Please see the FAQ entry How can I show HTML examples without them being interpreted as part of my document?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Sep 19 2008, 11:13 PM
Post #3


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



If you have the code you want to show in a string in PHP, just use

echo htmlspecialchars($string);

This removes anything that would mess up in html. You don't need to do anything special about "PHP code" as such.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 24th April 2024 - 12:18 AM