October 19th, 2000, 04:40 AM
Hi! Is there any possible way to view an "on-line" php file? That is of course how you can view the code in a php file?
October 19th, 2000, 05:10 AM
October 19th, 2000, 05:22 AM
Well, it kinda depends..
If you mean, can someone straying onto your website, choose the browsers "view source" option, and see your PHP source code? Then the answer is "No".
However, "if" you want your visitors to be able to see your source code, then you have to do a little extra work.
If you've been to PHP.NET, you'll notice that they have a "source" option on their site, which allows you to simply click the button, and see their source code.
This can be accomplished, at your discretion, by simply placing your "PHP" source in a file that is "not parsed" by the server, like a .htm or .html file, or whatever file extension, that the server does not pass through the PHP interpreter.
Then your PHP source code will be treated like standard document text, and displayed for the world to see.
So, as you can see the answer is simply Yes, and No.
A document being passed through the PHP interpretor is not viewable, while that which
is not passed to the interpretor can be viewed.
Low Cost Hosting and Web Development.
October 19th, 2000, 05:53 AM
What about file-leeching then? I suppose that I'll get the parsed document anyway, right?
October 19th, 2000, 08:04 AM
Just FYI Robert_J_Sherman,
If you want to show the source code of a php file, the best way to do it is use the php function show_source(filename). This outputs the pretty color/highlighted file you see on php.net...
And, for thejonas,
Basically no one can see your php code unless:
1. Your server is set up incorrectly and it passes the PHP as plain text. Solution: Set up server correctly, which is basically set it up according to the instructions, nothing special.
2. You provide them a link to view your source.
3. Someone hacks onto your server and gets permissions to read your files.
Those are the only ways I can think of...If there were a way to view the PHP code, then PHP would be worthless. There would be no security. That's why it's no big deal to list your passwords in a php file, because it's never sent to the browser. Your php never leaves the server.