为什么PHP脚本在Web浏览器中不起作用? [英] Why PHP script is not workig in a web browser?

查看:155
本文介绍了为什么PHP脚本在Web浏览器中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们都已经看到许多关于StackOverflow的问题,这些问题基于PHP就像Javascript一样的思想.该人员显然不了解PHP是 Preproccessor ,并且仅在发送页面之前有效.

We have all seen many question on StackOverflow that are founded upon the idea that PHP works like Javascript. Where the person clearly does not understand that PHP is a Preproccessor and only works before the page is sent out.

下面的代码是一个明显的例子,当用户按下按钮时,runCommand()将不会运行.

A clear example of this is in the following code, where runCommand() will not run when the user presses the button.

<a href="<?php runCommand(); ?>">Click Me!</a>

就像在Java语言中一样

as it would in Javascript

<a href="javascript:runCommand();">Click Me!</a>

我已经看到很多类似这样的问题,这些问题是来自新人们的,他们只是根本没有意识到PHP是如何工作的.

I've seen many questions like this that are from new people that just simply don't realize 'how' PHP works.

我的问题是:哪里有很好的资源来解释PHP的工作原理?.

我希望能够将人们重定向到一个页面,该页面可以使人们走上正确的路,并知道 Preproccessor 的含义.

I want to be able to redirect people to a page that can get them going on the correct track and know what being a Preproccessor means.

(这也使我变得懒惰,不必在每次出现时都写一个解释,但不要告诉任何人!)

如果您不了解描述得很好的地方,请随时提供自己的解释.

If you don't know of a place that describes this well, feel free to provide your own interpretation.

正如 Carl Smotricz 所指出的,PHP的一部分可以在浏览器之外使用.但是我主要是在Apache环境中谈论的,在该环境中,用户请求一个网页,并希望能从HTML中得到一些回报.

As Carl Smotricz points out, there is a part of PHP that can be used outside of the browser. But I'm mainly talking about in a Apache enviorment where a user requests a web page, and expects to get something back, usually in HTML.

推荐答案

Wikipedia始终是大量的信息资源.我建议:

Wikipedia is always a great resource of information. I suggest:

服务器端脚本

vs

客户端脚本

维基百科也有图片:

这篇关于为什么PHP脚本在Web浏览器中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆