What is the difference between php and js

ive looked at php files and js files and they look pretty much the same

What is the difference Between php and js
  • None they are the same
  • theres alot different
  • i have no idea
  • pretty much the same

0 voters

Just to make sure you didn’t mean nodejs or similar libraries right?

It’s really different!

JavaScript is a language run in your browser to make web pages interactive, PHP is a server side language run on a server that responds to requests. There are many similarities between PHP and JavaScript, but they are completely different.

JavaScript can be run at any time within a web page, it enables interactions between the user and the web page, but is very limited in abilities outside of this to ensure browsers are safe (both for the user and for the host).

PHP is only run when a request is made and returns HTML content. PHP can interact with a database based on some input in a request, then display an appropriate response.

In a shopping web page, PHP might provide the items that you can buy, whereas JavaScript may be used to enable the user to click on an item and add it to their cart (which could be stored locally in their browser).

JavaScript cannot (safely and securely) directly interact with a database.

1 Like

i meant like js you would put in a website script.js

thanks @MattDESTROYER i did not know this
the code in the php and the javascript seems alot alike
i did not notice they were that much different

1 Like

Yeah, I noticed that too when I first started learning PHP. They are both capable of many similar things, however they are also both capable of many things that the other can’t do. For example PHP can interact with files or a database directly, while JavaScript can be used to create animations, make things interactive or process some data before submitting it to PHP.