如果HTML,CSS和Javascript是客户端,为什么它们是PHP文件的组件? [英] If HTML, CSS, and Javascript are client-side, why are they components of a PHP file?

查看:167
本文介绍了如果HTML,CSS和Javascript是客户端,为什么它们是PHP文件的组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,最重要的是,原谅我完全缺乏网络开发的知识。我刚刚发现了对这个话题的兴趣,但我需要一些答案澄清事情。第二,我已经尝试过这个搜索,但找不到我正在寻找的答案。



我经常听到的术语服务器端和客户端关于web开发的编程。他们说,服务器端和客户端在一定程度上是相互分离的。从我的理解,服务器端编程使用PHP,Rails,Node,ASP.NET等,因为技术和客户端编程使用HTML,CSS,Javascript等。



这里是我根本困惑的..从我​​知道,PHP文件可以包括HTML,CSS和Javascript ...我的问题是:



如果服务器端和客户端编程是分开的,为什么PHP包括HTML,CSS和Javascript?如果所有这些都是在PHP,服务器,客户端在哪里进来?在PHP服务器上运行的典型网站中,是否存在不是PHP文件的独立HTML,CSS和Javascript文件?客户端开发人员是否已编辑PHP文件的HTML,CSS和Javascript部分,而服务器端开发人员使用该文件的PHP部分?



再次,对不起,我绝对没有网络开发经验,我希望这个问题的答案将清除一些事情对于像我这样的新手。

解决方案

您的问题肯定是很多人在他们的生活(网络开发人员)的某个时间问。
PHP确实是一个服务器端脚本,但 .php 扩展名像一个正常的 .html 文件大多数时候。



PHP需要与JS和HTML合作才能正常工作



例如登录表单。首先,客户已完成表单并提交。 JS然后上电,使用ajax发送您的登录信息到服务器(它可以是相同的文档xxx.php,但服务器只关心php脚本部分)。



然后,它从服务器发回一个结果,并且可以在您的登录表单中插入一段JS代码,其中JS授权并将用户从他们的HTML界面重定向到一个新的网站。



从上面的示例中可以看出,客户端和服务器对网页的处理方式不同,而忽略其文件扩展名。客户端无法下载PHP源代码,PHP服务器不在乎除了PHP代码本身。



一个web文件就像一个端口,客户端发送信息到php页面,服务器返回一个片段。



客户端和服务器可以使用一个.php页面,也可以引用不同的页面,但服务器端网页始终未更改 >




如果服务器端和客户端编程是分开的,PHP为什么包括HTML,CSS和Javascript?



因此,它可以在一个网页中紧凑地包装小东西。客户端查看接口,服务器执行PHP代码。



此外,可以查看 .php 扩展名由客户端,以便他们知道他们将与服务器在该页面的某个时间进行交互。另外, .php 不需要包括PHP代码。



如果所有这些都是在PHP中完成的,服务器,客户端在哪里进来?



客户端需要使用JS向服务器发送信息以获得响应。



在运行PHP的典型网页上,是否会有不是PHP文件的独立HTML,CSS和JavaScript文件?



不需要由PHP引擎解析,可以命名和存储为独立的HTML,CSS和JavaScript文件。



客户端开发人员已经编辑了HTML, CSS和JavaScript部分的PHP文件,而服务器端开发人员在文件的PHP部分工作?



我会将你的问题改为客户端浏览器可以改变DOM,而服务器工作在PHP部分?。没有客户端开发人员,只有客户端访客



部分正确。客户端下载网页,而不是在服务器上使用相同的文件,可以在发送到客户端之前更改网页。客户端不能读取PHP源代码,服务器在将网页发送到客户端之前运行PHP代码,因此两者不会一起运行。当客户端向服务器发送查询时,服务器只执行PHP。 .php文档在服务器上未更改。在PHP服务器响应之后,通常,它们将向查看特定网页的浏览器发送回信息,并触发JS代码并改变网页的DOM,这意味着网页的外观被修改。您可以将其解释为HTML,CSS和JS被更改。


First and foremost, forgive me for my complete lack of knowledge of web development. I have just recently found interest in this topic but I need some answers to clear things up. And second, I have tried searching for this before but couldn't find the answer I was looking for.

I often hear of the term server-side and client-side programming in regards to web development. They say that server-side and client-side are in a way decoupled from each other. From my understanding, server-side programming makes use of PHP, Rails, Node, ASP.NET, etc., as the technologies and client-side programming makes use of HTML, CSS, Javascript, etc.

Here is where I am fundamentally confused.. From what I know, a PHP file can include HTML, CSS, and Javascript... My question is:

If server-side and client-side programming are indeed separate, why does PHP include HTML, CSS and Javascript? If all of these are done in PHP, the server, where does the client come in? In a typical website run on a PHP server, will there be standalone HTML, CSS, and Javascript files that are not PHP files? Will the client-side developer have have edit the HTML, CSS, and Javascript parts of the PHP file, while the server-side developer works on the PHP part of the file?

Again, sorry, I have absolutely 0 experience with web development and I hope the answer to this question will clear up some things for newcomers like me.

解决方案

Your question sure is a good one many people asked sometime in their lives(web developers). PHP indeed is a server side script, but the .php extension acts like a normal .html file most of the time.

PHP needs to be a partner with JS and HTML to work.

E.g. A login form. First, the client has completed the form and submitted it. JS then comes in power, using ajax to send your login information to the server(It could be the same document xxx.php, but the server only cares about the php script part).

Then, it sends back a result from the server and may insert a snippet of JS into your login form, where JS empowers and redirect the user from their HTML interface to a new website.

As you can see from the above example, clients and server handles a webpage differently disregarding their file extension. Clients cannot download the PHP source code and the PHP server doesn't care about other than php code themselves.

A single web file is like a port, where clients send information to a php page and the server returns a snippet.

Clients and servers may use one single .php page or can refer to different pages, but the server side webpage is always unaltered


If server-side and client-side programming are indeed separate, why does PHP include HTML, CSS and Javascript?

So it can compactly pack small things inside one web page. Clients view the interface, server executes the PHP code. However, it is not necessary to pack everything into one webpage.

Also, the .php extension can be viewed by clients, so that they know they will interact with the server sometime on that page. Also, .php does not necessary need to include PHP code.

If all of these are done in PHP, the server, where does the client come in?

Clients need to use JS to send information to the server for its response.

On a typical webpage running on a PHP, will there be standalone HTML, CSS, and JavaScript files that are not PHP files?

Yes, files that need not to be parsed by the PHP engine can be named and stored as standalone HTML, CSS and JavaScript file.

Will the client-side developer have have edit the HTML, CSS, and Javascript parts of the PHP file, while the server-side developer works on the PHP part of the file?

I will rephrase your question to be "So the client-side browser can change the DOM, while the server works on the PHP part?". There is no "client sided developer. There is just client sided visitors"

Partially right. Clients download a webpage, not using the same file on the server, the webpage can be altered before sending to the clients. Clients don't get to read the PHP source code, the server is done running the PHP code before sending a webpage to the clients, so the two do not run together. When clients send queries to the server, the server executes nothing but PHP. The .php document is unaltered on the server. After the PHP server has responded, usually, they will send back information to the browser viewing that particular webpage and trigger JS code and change the webpage's DOM, which means the look of the webpage is modified. You can interpret it as "HTML, CSS and JS" being altered.

这篇关于如果HTML,CSS和Javascript是客户端,为什么它们是PHP文件的组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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