Page 1 of 1

php code view like a text?

Posted: Sun Jan 15, 2012 1:49 am
by jayson.ph
Hi all, how to post an php code or html code that can view like text?

Re: php code view like a text?

Posted: Sun Jan 15, 2012 5:43 am
by twinedev
save a copy adding .txt to the end of the file.... myscript.php => myscript.php.txt

Or do you mean set it so that any .php in a certain directory (.ie and uploads directory where people can upload files) does not execute (I have seen sites get hacked this way).

If so, then add something like the following into an .htaccess file in that directory:

Code: Select all

AddType text/plain .pl .cgi .php
Be sure to add all variations that work on your server.... (.php, .php4, .php5, .phtml etc)

-Greg

Re: php code view like a text?

Posted: Mon Jan 16, 2012 12:34 am
by jayson.ph
i mean is, i want to post a php code in a website, like a tutorial. when the visitor open the website he/she can see actually the code tutorial. like this website. http://www.w3schools.com/php/php_mail.asp

Re: php code view like a text?

Posted: Mon Jan 16, 2012 4:04 am
by twinedev
All you have to do is use the correct entities (see http://www.w3schools.com/html/html_entities.asp) on the code and the either style a div to hold it, or wrap with <pre><tt> </tt></pre> to have ti be fixed width and keep all spacing.