Best way to setup a php layout?

Discussion in 'PHP' started by wwwbryan, Jun 16, 2009.

  1. #1
    What is the best way to setup a php layout?

    Is it to use a class?

    Use functions and call on them when necessary, such as

    includeHeader();
    includeMenu();

    Or what?
     
    wwwbryan, Jun 16, 2009 IP
  2. UnknownOne

    UnknownOne Banned

    Messages:
    466
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yeap!
    That in fact is my chosen option.
    Best to place all your functions in one page(x.php), include the page in every other page using the include(); function. And when you need to use the function, you can simply call it.
    If you ever need to edit your sites theme, all you have to do is simply edit one file(x.php) and your site/linked pages will be transformed according to your settings.
     
    UnknownOne, Jun 16, 2009 IP
  3. bluebenz

    bluebenz Well-Known Member

    Messages:
    876
    Likes Received:
    9
    Best Answers:
    2
    Trophy Points:
    138
    #3
    Put the function that you will always needed by your script in 1 files.
    That make you have less line code.
     
    bluebenz, Jun 16, 2009 IP
  4. wwwbryan

    wwwbryan Well-Known Member

    Messages:
    181
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #4
    Umm... Duh? :rolleyes:
     
    wwwbryan, Jun 16, 2009 IP
  5. mukaanyes

    mukaanyes Well-Known Member

    Messages:
    89
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    113
    #5
    so, what really make you have less lines of code?
     
    mukaanyes, Jun 16, 2009 IP
  6. Social.Network

    Social.Network Member

    Messages:
    517
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    35
    #6
    Include all functions in one page? Are you kidding? Imagine including a 1,000+ line file on every page just to call a couple of helper functions.

    If you want to learn how to properly structure projects and design PHP-based solutions, take a look at the PHP 5.x frameworks for reference.
     
    Social.Network, Jun 16, 2009 IP
  7. juust

    juust Peon

    Messages:
    214
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Do you intend to use caching ?
     
    juust, Jun 16, 2009 IP
  8. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #8
    there is no single right way for PHP code .. it depends on what youre doing, and like mentioned above, you dont want a giant overhead in file size , if you only need a few functions.

    part of PHP programming skill is learning how to make better , faster working scripts, etc.
    So asking how to do PHP in a single 'right way' .. is like asking how do you build a bridge in the single right way.
    It all depends where its at.
     
    ezprint2008, Jun 16, 2009 IP
  9. wwwbryan

    wwwbryan Well-Known Member

    Messages:
    181
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #9
    The way I have it is it includes a class on each page. Then when the page requires say the navigation menu, it calls for the function inside the class that contains the navigation. And I don't want to use a framework because its like learning another language...
     
    wwwbryan, Jun 17, 2009 IP
  10. webdesigners

    webdesigners Banned

    Messages:
    534
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #10
    If you are not familiar with php but know something abt coding in html/php than you can use wordpress cms to design.
     
    webdesigners, Jun 17, 2009 IP
  11. pipes

    pipes Prominent Member

    Messages:
    12,766
    Likes Received:
    958
    Best Answers:
    0
    Trophy Points:
    360
    #11
    I imagine the OP wants more than what wordpress offers though.
     
    pipes, Jun 17, 2009 IP