Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
115
rated 0 times [  121] [ 6]  / answers: 1 / hits: 19846  / 14 Years ago, fri, february 25, 2011, 12:00:00

is it possible to run some javascript expression? for example echo eval(Math.sqrt('25'));


More From » php

 Answers
22

In normal situations :




  • PHP runs on the server

  • and, then, Javascript is run on the client, in the browser.



So, no, it's not quite possible to have PHP execute some Javascript code on the server.





But there is at least on PHP extension that embed (or wrap arround) a Javascript engine, and, as a consequence, allows one to execute Javascript on the server, from PHP.



The extension I'm thinking about is the spidermonkey one : installing and enabling it on your server will allow you to execute Javascript code, on the server, from PHP.



Of course, like any other PHP extension, you'll need to be admin of your server, in order to install it -- and this one is never installed by default, as it answers a very specific need.





About this extension, I have never seen it used in real situations, and there are not many people who tried it... here are two articles you might want to read :




[#93573] Thursday, February 24, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
destanyb

Total Points: 407
Total Questions: 88
Total Answers: 88

Location: Senegal
Member since Mon, Sep 5, 2022
2 Years ago
;