Showing posts with label PHPS. Show all posts
Showing posts with label PHPS. Show all posts

Wednesday, 22 April 2015

Display PHP code in the browser

There are 2 ways to do this I've recently discovered:
First, use the highlight_file command thus,

Second, allow .phps files. To do this (I'm using an Ubuntu Apache on local host here), go to the file /etc/apache2/mods-available/php5.conf
Change the line highlighted in red to the one highlighted in blue
<FilesMatch ".+\.phps$">
    SetHandler application/x-httpd-php-source
    # Deny access to raw php sources by default
    # To re-enable it's recommended to enable access to the files
    # only in specific virtual host or directory
    Order Deny,Allow
    Deny from all
    Allow from all
Now, if you rename hello.php to hello.phps and display it in your browser, it will show as PHP code.
Hope this helps.