Why is PHP only called once in JavaScript?

That is because php is run on the server side, before JavaScript is loaded, meaning the php function is only called once when the page loads and not each time the JavaScript function is called. That is why functions that accept parameters cannot return the result of a php function passing the parameters into the php function.
For More Information Please Refer:

You May Also Like to Read: