Website Structure

后端 未结 9 686
无人及你
无人及你 2021-02-04 19:43

I\'m pretty new to php and i\'m trying to decide the best way to organize the pages and, using PHP, deliver them. The two (basic) ideas I\'ve had are:

  • A bunch o

相关标签:
9条回答
  • 2021-02-04 20:17

    The main with PHP is that you need to "KEEP THE PRESENTATION AND PROGRAM LOGIC SEPARATE". Or in other words, make sure that you aren't echoing html to the screen in the middle of the scripts that you do your business or processing logic in.

    Your second solution is a fairly common (and not a bad) solution to the problem. It allows you to build a single page with all of your layout information which then includes the specific page content to be rendered. Obviously this won't work so well if you need to swap large portions of the layout template from one page to the next. In that case, your first solution would work better.

    Lastly, I would strongly recommend that you take a look at the various PHP frameworks out there like Zend Framework, Symfony, or CakePHP to see how they all handle this problem. If you find one you like, then just use it. Otherwise you're still likely to get some great ideas on how to structure your own site.

    0 讨论(0)
  • 2021-02-04 20:22

    Why going only half way the right direction? Use one of existing MVC frameworks. They are powerful tools that structure the code probably much better than any custom solution. Go for MVC, learn how to separate business logic from presentation logic and from data structure, increase your value on the job market as a potential employee, save your time and be happy.

    • Zend Framework
    • Cake PHP
    • Symfony Framework
    • Kohana PHP

    You should probably start (but not limit yourself to) Kohana PHP as it has mild learning curve.

    0 讨论(0)
  • 2021-02-04 20:24

    It makes your life much easier to have menu and headers in header.php and footer, sopyright etc. in footer.php. Then just include those files into each page you create.

    0 讨论(0)
提交回复
热议问题