logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: php & html or html & php - best practice?
Author
food monkey



Joined: 27 Aug 2010
Posts: 4
Location: Australia

PostPosted: Sun 29 Aug '10 15:00    Post subject: php & html or html & php - best practice? Reply with quote

is it better to code php and use include for specific html pages or code in html and execute php scripts?

what's best practice - i've scoured the forums and can find no general consensus as to which way to go.

cheers.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7355
Location: Germany, Next to Hamburg

PostPosted: Sun 29 Aug '10 17:34    Post subject: Reply with quote

Depends on what you want to do and how readable the code shall be. For speed it is better to use html code and embed the php code.


e.g.
Code:

<p><?php do_something(); ?></p>


Well that can safe some execution time but it maybe not readable as if you include the html code. As far I can tell it is best practice for me to have a better code to read than over and over optimizing the code. If the code execution is under a second but the website is still to slow buy better hardware.

What might help is an older but good presentation from Ilia Alshanetsky one of the PHP Dev guys
Back to top
food monkey



Joined: 27 Aug 2010
Posts: 4
Location: Australia

PostPosted: Wed 01 Sep '10 15:03    Post subject: Reply with quote

thanks James Blond.

i'm actually thinking of using html with simple php statements that include the specific script from another directory on the site - this way i keep almost complete separation of layout and scripting.

it alos allows me to simply have the php script execute a stub until i'm happy with the structure and flow of the site before putting in the scripts that will do the grunt db work.

basically the scripts become black boxes that i can change the behaviour of without impacting the structure of the website (yeh i know spot the OO guy).

anyway thanks for your help.
Back to top


Reply to topic   Topic: php & html or html & php - best practice? View previous topic :: View next topic
Post new topic   Forum Index -> Apache