为什么在查看源代码时看不到我PHP代码?

Web developers and others who are knowledgeable about web pages know you can use a browser to view the HTML source code of a website. However, if the website contains PHP code, that code is not visible, because all the PHP code is executed on the server before the website is sent to a browser. All the browser ever receives is the result of the PHP embedded in the HTML. For this same reason, you cannot go to a .php file on the web, save it, and expect to see how it works. You are only saving the page produced by the PHP, and not the PHP itself.

Web开发人员和其他了解网页的人都知道您可以使用浏览器来查看网站HTML源代码。 但是,如果网站包含PHP代码,则该代码不可见,因为所有PHP代码都在网站发送到浏览器之前在服务器上执行。 浏览器收到的所有内容都是HTML内嵌PHP的结果。 出于同样的原因,您不能进入。 网页上的php文件 ,将其保存,并希望了解其工作原理。 您只保存由PHP生成的页面,而不保存PHP本身。

PHP is a server-side programming language, meaning it is executed at the web server before the website is sent to the end-user. This is why you can't see the PHP code when you view the source code.

PHP是一种服务器端编程语言,这意味着它在网站发送给最终用户之前在Web服务器上执行。 这就是为什么在查看源代码时看不到PHP代码的原因。

示例PHP脚本 ( Sample PHP Script )

When this script appears in the coding of a web page or .php file that is downloaded by an individual to a computer, that viewer sees:

当此脚本出现在个人下载到计算机的网页或.php文件的编码中时,查看者将看到:

My PHP Page

Because the rest of the code is just instructions for the web server, it isn't viewable. A view source or a save simply displays the results of the code—in this example, the text My PHP Page.

由于其余代码只是Web服务器的说明,因此无法查看。 视图源或保存仅显示代码的结果-在此示例中,文本为My PHP Page。

服务器端脚本与客户端脚本 ( Server-Side Scripting vs. Client-Side Scripting )

PHP isn't the only code that involves server-side scripting, and server-side scripting isn't limited to websites. Other server-side programming languages include C#, Python, Ruby, C++ and Java. 

PHP不是唯一涉及服务器端脚本的代码,并且服务器端脚本不仅限于网站。 其他服务器端编程语言包括C#,Python,Ruby,C ++和Java。

Client-side scripting operates with embedded scripts—JavaScript is the most common—that are sent from the web server to a user's computer. All the client-side script processing takes place in a web browser on the end-user's computer. 

客户端脚本使用嵌入式脚本(最常见JavaScript)进行操作,这些脚本是从Web服务器发送到用户计算机的。 所有客户端脚本处理都在最终用户计算机上的Web浏览器中进行。

翻译自: https://www.thoughtco.com/why-dont-see-code-viewing-source-2694210

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值