Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

display contents of a PHP file with apache/php

Hi guys,

I want to display the contents of a PHP file with the proper syntax hi-lightning, as you view it in VIM, without executing its contents. I'm sure that I've seen this on apache/php documentation but can't remember were.
0
SHEEP
Asked:
SHEEP
  • 3
1 Solution
 
glcumminsCommented:
You can rename the file *.phps. As long as your webserver has the appropriate type setup (most do), your file will be displayed with syntax highlighting.
0
 
steelseth12Commented:
If your server doesnt have the correct setup or you dont want to change the extension you can use

highlight_file()

http://www.php.net/manual/en/function.highlight-file.php

or

highlight_string() for highlighting just a part of the code

http://www.php.net/manual/en/function.highlight-string.php

0
 
SHEEPAuthor Commented:
Cheers steelseth12 but ain't there a way to do it with any file type, like sh, pl, reg, etc?
0
 
steelseth12Commented:
highlight_file() is a php function so it needs to pass thought the php parser.

highlight_file() can read any file regardless of its extension.

If you want php the parse files other than the default you will need to add the doc type to the httpd.conf

e.g

AddType application/x-httpd-php .pl
0
 
steelseth12Commented:
note: if you are you are going to get into that ... you might as well do

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

so you will not need to run the highlight_file() function
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now