0

JavaScript Vs PHP

What is the Difference between these two? Both of them can be embedded inside HTML. What are the Advantages of learning JavaScript over PHP and vice versa?

2nd Nov 2017, 8:22 AM
HariHaran Yuvaraj
HariHaran Yuvaraj - avatar
4 Answers
+ 6
Not "both of them can be embedded inside HTML". JS can be embedded inside HTML, and HTML can be embeded in PHP (not reversly)... PHP scripts are running on server side, JS run at user side... (ok, JS can also replace PHP at server side, as any script language, but that's another story ^^) When PHP script run, it build and send HTML without any PHP code on client (user side) having requesting the document. When document is loaded, embedded JS script(s) can run...
2nd Nov 2017, 11:57 AM
visph
visph - avatar
+ 5
PHP is still the most used language at server side, but there's growing alternatives in almost script languages (JS but also Python, Ruby, or even Java)... As anything, there's advantages AND disadvantages in any of them, and choice of any is almost a taste question. One of advantages of PHP is that you find PHP host providers very easily, and that it have a hudge user base... anyway, from my point of view, this is the oldest slowly dying and future would see others take from more to more place. (Also, lot of big website use many of them depending on wich of their functionalities ;))
2nd Nov 2017, 9:11 PM
visph
visph - avatar
0
Yes right visph Not both because PHP is server side language And Html and Js are client side languages 1.) in Js file we can write only Js 2.) In html we can use html and Js (and Js under script tag) 3.) In PHP we can use PHP,HTML,Js,CSS
2nd Nov 2017, 12:54 PM
vaibhav sethi
vaibhav sethi - avatar
0
thank you @visph . But if JavaScript can replace PHP at server side , then why PHP is still in use ? Is there any specific advantage or reason, to learn and use PHP ?
2nd Nov 2017, 9:04 PM
HariHaran Yuvaraj
HariHaran Yuvaraj - avatar