W
W
Wild Dima2018-01-28 13:15:51
PHP
Wild Dima, 2018-01-28 13:15:51

Why is js used on the client and not php?

Why is no one using <?= ?> instead of js? In my opinion, this is many times more convenient than learning js as well.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
Y
youngmysteriouslight, 2018-01-28
@dmitrygoreliy

Maybe I did not understand the context of the question, but none of the proposed answers does not answer the question posed. So why is JS currently being used on the client and not PHP?
In short: this is how it happened historically.
PHP was originally compiled as an interpreted scripting language for server-side homepage generation, later developed into a complete server-side programming tool.
JS was commissioned to be implemented in one particular browser and was first announced before the release of the second beta version of Netscape Navigator. Then he downloaded it in the form of dialects to other browsers, because many people liked the idea of ​​​​DHTML (markup in HTML, design in CSS, interactive and other client-side logic in JS). Then it was standardized, and after 2009 the trash started.
In some alternate universe, the first browser could use PHP as the client scripting language, and in that universe, both the server and the client could use PHP, and that would be somewhat convenient.
In ours, they are trying to do the opposite thing: run JS on the server so that both the client and the server have the same language (google: isomorphic JS). The chances that PHP scripts will be natively executed on the browser are zero. Even dart didn't catch on.

A
archelon, 2018-01-28
@archelon

because php runs on the server and js runs in the browser.

O
Optimus, 2018-01-28
Pyan @marrk2

PHP needs an interpreter, there is no PHP interpreter in the browser. It's all )))

T
Twelfth Doctor, 2018-01-28
@verdex

Why is no one using <?= ?> instead of js?

Because it's inconvenient. Frameworks have built-in templating engines - for example, Laravel's Blade, which is ten times more convenient than And yes, JS is still a language that runs on the client, and PHP is a server language. Those. rendering is handled by the client, not the server. <?=?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question