954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

php in <head>

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?

Nichito
Posting Virtuoso
1,602 posts since Mar 2007
Reputation Points: 424
Solved Threads: 57
 

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

Cerberus
Junior Poster
162 posts since Sep 2006
Reputation Points: 27
Solved Threads: 14
 

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?

Nichito
Posting Virtuoso
1,602 posts since Mar 2007
Reputation Points: 424
Solved Threads: 57
 

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.

stymiee
He's No Good To Me Dead
Moderator
3,360 posts since May 2006
Reputation Points: 161
Solved Threads: 38
 

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

dr4g
Junior Poster
136 posts since Apr 2007
Reputation Points: 35
Solved Threads: 5
 

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

That's probably what would work for you.

WhiteLeo
Newbie Poster
16 posts since Feb 2007
Reputation Points: 10
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You