view source for html, how can I see .php code

view source for html,  how can I see .php code
shopjdAsked:
Who is Participating?
 
AlexanderRConnect With a Mentor Enterprise Web DeveloperCommented:
Sorry.

$output = highlight_string($source_file, true);

if you want the highlighted version to be saved in a string, otherwise its just
highlight_string($source_file);
on the second line
0
 
crokeefe28Commented:
cant be seen (unless you make an error)

serverside rendering.

All you should see is includes or variable output in the markup as if it was written in (x)html (ie no php code)
0
 
Cornelia YoderArtistCommented:
You cannot.  The php runs on the server, and then sends the HTML to the user's browser.  

This is as it should be, since you don't want any user to be able to see your code, database passwords, database information.

And you certainly wouldn't want any user to be able to modify a php script and submit it to your server.
0
2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

 
AlexanderREnterprise Web DeveloperCommented:
Rename file to .phps  .  Or create a script that does it for you.

You can also parse the file through one of the many PHP source viewers like http://www.softswot.com/sourcehelp.php
0
 
agamalCommented:
if you want to see a source code of php file on other sites ... then the only way to find a bug in the code ... or generate one ;-)

then maybe you will be able to see part of the code


if you want visitors to your site to see php code ... you can use the simple way and save the file as PHPS as AlexanderR said .. or even .txt file

0
 
adammm89Commented:
There's also a function called "highlight_string()" which will output the PHP code supplied with the syntax highlighted. However as the other guys have pointed out it's never really a good idea to show your source.
0
 
shopjdAuthor Commented:
There's also a function called "highlight_string()" which will output the PHP code supplied with the syntax highlighted. However as the other guys have pointed out it's never really a good idea to show your source.

how could this be used to show ALL the code from one php file
0
 
AlexanderREnterprise Web DeveloperCommented:
<?php
$source_file = file_get_contents("file_name_wih_source.php");
$output = highlight_string($source_file);
0
All Courses

From novice to tech pro — start learning today.