Kristen Martinson
Kristen Martinson

Reputation: 1869

how to load a php file to just display the contents of the file, not executing it?

how to load a php file to just display the contents of the file, not executing it?

I want to see the contents on a web browser. But I can't find a way to load without it executing the contents.

thanks

Upvotes: 2

Views: 102

Answers (4)

Stephen
Stephen

Reputation: 3432

If its just one large block, you could remove the tags..

otherwise, just rename the file to whatever.php.txt and load it in a browser..

Upvotes: 0

djhaskin987
djhaskin987

Reputation: 10107

If you're programming in php in order to view a PHP file, simply load the file into a string, then run it through htmlentities before displaying it. It will escape all the html special characters and cause it to be displayed literally.

Upvotes: 1

Shi
Shi

Reputation: 4258

If you want nice colouring, try highlight_file().

Upvotes: 3

Kerrek SB
Kerrek SB

Reputation: 477640

A combination of fopen and fpassthru should do the trick. Don't forget to send appropriate headers first. Alternatively readfile.

Upvotes: 0

Related Questions