SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict elemental70's Avatar
    Join Date
    Mar 2002
    Location
    Canada
    Posts
    240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Separate php from html?

    We know we can and should separate css and javascript from our html. But can we do the same with php? Call it "unobtrusive php" Just link t the script from the html file?
    This is something I've been wondering, and thought I'd get some feedback from all you gurus as I'm yet a beginner.

    Thanks all

    elemental

  2. #2
    An average geek earl-grey's Avatar
    Join Date
    Mar 2005
    Location
    Ukraine
    Posts
    1,403
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, template engines, such as Smarty and PHP TAL, can help you to do that.

  3. #3
    SitePoint Addict Skookum's Avatar
    Join Date
    Sep 2006
    Location
    Idaho
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I do with mine is that I use includes and requires like
    PHP Code:
    require_once 'required/PHPFunctions.php'
    The problem with that is that you have to save your files as PHP rather than HTML, but it keeps most of the PHP out of your web pages.

    You can also set IIS and or Apache to pass HTML files through the PHP parser also, that way you can still include files, or include PHP with .html extentions.
    Paranoia is no longer a mental illness it is a way of life - Me

  4. #4
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Templates are the way to go. You don't have to go for a big engine like Smarty, with its own 'internal' langauge. Instead it can be good to define a bunch of functions, such as showContent() showMenu() etc... Then in your index file prepare your data, load your template file, and let it call the necessary functions so as it will display the relevant parts on teh correct places.
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •