i am a newbie in learning php, and i would like to know if php can be used just as javascript being initialized in the head of an html docment to be called whenever you need it?

I don't think you can do that at all with PHP because it need to be processed by the PHP engine (server side).

so, when i write php, it must be written down in the body, so when loaded it is able to communicate with the server?

so php functions cannot be called when you need them?

PHP is executed on the server, not in the browser. So it doesn't matter where you put it. If you want something executed in the browser you must use JavaScript.

You can execute PHP in any part of your HTML page, for example witin the <head>

You can look up AJAX, which is php functions executed on the fly by javascript.

That's probably what would work for you.