The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
Scripts / handy tips
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 displaying php code
Author: Dan Langille 
Date:   29-07-02 03:25

If you want to view your php code on the website, give your file a .php extension.

For example, see http://www.freebsddiary.org/samples/example.php and compare it with http://www.freebsddiary.org/samples/example.phps.

Reply To This Message
 
 Re: displaying php code
Author: .daniel.schrock 
Date:   29-07-02 17:30

on a related note:

This can be completely disabled in the php.ini file.

Reply To This Message
 
 Re: displaying php code
Author: John Prather 
Date:   26-03-03 19:32

The php source option needs to be in your httpd.conf for this to work with a line like:

AddType application/x-httpd-php-source .phps

Also, if you are still working on the file, you can symlink it so that changes you make to the .php file are displayed on php source webpage.

ln -s exampe.php example.phps

This way you won't have two copies of the same file confusing you if a slight change is made to one.

(and i think the original post meant to rename the file .phps, since one assumes the file already ends in .php)

Reply To This Message
 
 Re: displaying php code
Author: Jeff 
Date:   28-09-03 15:01

Sweet thanks!

John Prather wrote:
> The php source option needs to be in your httpd.conf for
> this to work with a line like:
>
> AddType application/x-httpd-php-source .phps
>
> Also, if you are still working on the file, you can symlink it
> so that changes you make to the .php file are displayed on php
> source webpage.
>
> ln -s exampe.php example.phps
>
> This way you won't have two copies of the same file confusing
> you if a slight change is made to one.
>
> (and i think the original post meant to rename the file .phps,
> since one assumes the file already ends in .php)

Reply To This Message
 
 Re: displaying php code
Author: Matthew Deville 
Date:   04-11-04 13:13

How do you display php code in a page, rather than displaying the whole source of a php page?



Reply To This Message
 
 Re: displaying php code
Author: csinclair 
Date:   05-09-06 19:06

If I understand the question correctly..
If the source is displayed instead of the page then the default .php is not set correctly in the httpd.conf file for the web server. Peruse the httpd.conf file for the line that reads..: DirectoryIndex index.html, change it to read ..:

DirectoryIndex index.php index.html .

Also make sure that the above mentioned directives are stated as well..

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

If all that is done and the apache server is restarted (ie. 'apachectl restart') it should work..
If that's not your question I'll read the next post and see if I can help.

Hope that helps..
c

Use the source Luke...

Reply To This Message
 
 Re: displaying php code
Author: Dan 
Date:   05-09-06 19:16

A good answer. That's what is needed should someone be seeing PHP code instead of the rendered HTML.

Thanks.

--
Webmaster

Reply To This Message
 
 Re: displaying php code
Author: csinclair 
Date:   21-11-06 16:21

No Problem,
I'm glad that that my post helped, I've wrestled with enough code over the years to know that a helpful answer to a well asked question is worth it's weight in gold, not to mention the time that it will save you.

;)
Craig

p.s. This web site has saved me hours and hours of headaches in the last few years by having a well organized, well structured topic list.

Thanks Dan!

Use the source Luke...

Reply To This Message
 Forum List  |  Threaded View   Newer Topic  |  Older Topic 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org