4 Replies - 8902 Views - Last Post: 16 June 2010 - 08:50 AM Rate Topic: -----

#1 Codin  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 45
  • Joined: 31-March 10

Where does the PHP go?

Posted 15 June 2010 - 04:35 PM

Html and Javascript is not a problem for me. I am new to PHP and I was wondering does the PHP always go into the body section. Or is it like Java script if you put it in the body it loads right away and if you put it in the head it loads after the page is loaded. Thank you. :gunsmilie:
Is This A Good Question/Topic? 0
  • +

Replies To: Where does the PHP go?

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10660
  • View blog
  • Posts: 39,580
  • Joined: 27-December 08

Re: Where does the PHP go?

Posted 15 June 2010 - 04:43 PM

PHP is a server-side language; and as such, is processed by the Server. As such, it treats all HTML, CSS, and other Scripting as Strings. As it is processed by the server, the HTML/CSS and Scripting are sent to the client/browser to be interpreted. Then when the user interacts with forms, that data is sent back to the server to be processed by the PHP.
Was This Post Helpful? 1
  • +
  • -

#3 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5364
  • View blog
  • Posts: 27,325
  • Joined: 10-May 07

Re: Where does the PHP go?

Posted 15 June 2010 - 06:51 PM

PHP can be placed in more than just the body. I use PHP to dynamically set the title in the head html segment or load custom css.

As macosxnerd101 pointed out, PHP is a server side language, meaning that by the time the browser gets the code, the PHP engine has already processed the PHP code & prepared the web site for viewing by the browser. The browser then processes the HTML, css, Javascript & any other technologies.
Was This Post Helpful? 2
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10660
  • View blog
  • Posts: 39,580
  • Joined: 27-December 08

Re: Where does the PHP go?

Posted 15 June 2010 - 09:17 PM

You may also need to put PHP before your HTML and other headers are sent (ie., any output) so you can do things like set cookies, start a session, or redirect the page using the header() function.
Was This Post Helpful? 1
  • +
  • -

#5 Codin  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 45
  • Joined: 31-March 10

Re: Where does the PHP go?

Posted 16 June 2010 - 08:50 AM

Thank you very much for answering my questions.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1