Most network programs are in C/S mode, that is, the client and server transmit data and interact with each other. Web applications are in C/S mode, and the browser serves as a universal client, so we often use B/S to describe this mode. In the Web, the client (browser) is the front end, the server is the back end, and the front and back are relative to the programmer.
I don’t think it’s appropriate to say whether PHP is used for front-end or back-end. PHP runs on the back-end (server side), and the running results will be sent to the front-end (client, browser) for display.
Just like the editor of a newspaper office, he writes the article in the newspaper office, prints it in the newspaper, and then sends it to you for you to read. From my personal understanding, there is actually a difference between front-end in a narrow sense and front-end in a broad sense.
Everyone has already made it clear that the front end in the narrow sense is "the visible part (in the browser)". The main technologies are HTML, CSS, JavaScript, Flash, siverlight, etc.
The broad front-end includes the page output by the server to the user's browser, which is the View layer in the MVC framework. The corresponding back-end is service and data access. In the server, the front end will encapsulate part of the logic of page display. For example, when rendering a table, a loop will be made at this layer (of course it can also be rendered with js), or a form will be produced. Because it is executed on the server side, the advantage is that it is fast and safe.
Of course, the function of PHP is not limited to the output page, but also the logic layer, service layer and DAO, and perhaps reading and writing files, message queues, event mechanisms, etc. Strictly speaking, PHP does much more on the backend than on the frontend. Different companies may have different understandings of this. I think there is no need to be serious about this. Even students who work in narrow front-end work will be very beneficial to understand the PHP framework.
The above is the detailed content of Is php front-end or back-end?. For more information, please follow other related articles on the PHP Chinese website!