开发者

Can php files be viewed across the internet like html files?

if I want to view the code of a web page written in html I just need to right click and select view source. Can the same be done with php files so I can learn how certain tasks are being accomplished开发者_StackOverflow中文版? Is there a way to hide the code?


Unless the server is very improperly set up, no. Very no.

For example, at the top of my "includes/database.php" file, I have three lines that look like

$host = "localhost";
$username = "myuser";
$password = "mypassword";

You can see why I'd not want that publicly visible...


Generally no and I will tell you why.

What happens is that the browser is asking for a file that the web server can serve to the user. The file has the extension .php for example. The web server is setup so whenever he gets a request for a file with that extension he has to run it through PHP first and use the output from PHP as the output to serve the user.

So the user asks for a file, the web server finds it, sees that PHP has to process it first, PHP does and gives the web server the output (whatever it is) and the web server then gives the user that content.

It can happen that the web server is configured in the wrong way and skips the PHP step, so then the user sees pure PHP but this is very rare and usually spotted immediately.


No, they can't. PHP is a server-side scripting language, the browser never actually sees the php code.


absolutely no way. PHP is processed before being outputted to the browser so its all server side!


You can only view the code if the file extention is .phps


Hypertext pre processor is interpreter which understand the code and convert into html form with the help of webserver so it is notable to view on webserver
But on local machine without Webserver we can see the code

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜