Can a programming language be both client and server?

What I mean, mainly, for example, PHP, PHP can be used both for outputting data to a client / browser, and for connecting / querying databases.

Will it be both client side and server side programming language?

Or it is still a server language, since its main use is a database query

Javascript too, js can be used as a client-side language, as it is, but can it also be used to establish a connection to the database, does it as a programming language on the server and on the client side?

thanks.

+5
source share
4 answers

PHP is technically the “client” of your MySQL server, but the “client side” in web development refers to the code that runs in your custom web browser. PHP is a server-only technology (prohibiting oddities such as PHP-GTK).

JavaScript is both client-side (in the browser) and server-side (via Node).

+5
source

What the client-side programming language does (if we are talking about web development) is that it runs in a web browser.

JavaScript is both a client and server language because it can be used to develop a client application in your browser (or even mobile applications using environments such as Apache Cordova), as well as a backend technology due to runtimes like NodeJS, which is fully executed on the server machine.

PHP is a server language (1) and the fact that PHP scripts can act as clients of other server environments or technologies does not mean that it is a client-side language.

The term "client side" refers to another physical layer from the server, which usually has a graphical user interface.

(1) In fact, it is true that PHP can be used to develop other types of applications, such as desktop applications, BTW, its main use is server-side web development.

+3
source

Javascript can be used as a front-end and back-end interface language. For example, AngularJS is used for the front end, and NodeJS is used for the backend. NodeJS runs on the server, and AngularJS runs in the browser.

PHP is a server-side programming language. PHP runs on a server, not a web browser. PHP can output data to the browser, but it actually runs on the server. PHP is the "Hypertext Preprocessor". The PHP processor processes the PHP code and returns the final HTML code.

+1
source

The client / server side is not a feature of the language, but simply a place where you use it in each case.

Even in web development, while JavaScript dominates the client domain for historical reasons, there are no technical reasons that would prevent you from using any other language inside the browser using script nodes in the window — for example, to search for PerlScript — or implement JS- based translator / interpreter / compiler.

0
source

Source: https://habr.com/ru/post/1238529/


All Articles