SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: header page

  1. #1
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    header page

    I have the header.php which has the basic logic applying to all php files inside web root folder.

    Let's suppose I have the following 5 pages "index.php, post.php, list.page, read.page, update.page" in the folder.

    Index.php begins with <?php include "header.php" ?> .
    post.php begins with <?php include "header.php" ?> .
    list.php begins with <?php include "header.php" ?> .
    read.php begins with <?php include "header.php" ?> .
    update.php begins with <?php include "header.php" ?> .

    All php files in the folder begins with <?php include "header.php" ?> .

    I doubt why I should put the code "<?php include "header.php" ?>" in all php files in the folder.
    I'll be happy if all php files in the folder has the code of header.php automatically without the code <?php include "header.php" ?>.


    coldFusion has this kind of function.
    The file of the name is "application.cfm"

    When a user open any coldFusion(cfm) files in a folder,
    coldFusion server searchs application.cfm in the folder before it reads the requested cfm files.

    If application.cfm is in the folder, it reads application.cfm first and reads the requested cfm file.

    If application.cfm is not in the folder, it reads the requested cfm file.

    If a user calls application.cfm directly, it causes error.

    Application.cfm is not a url file.
    Application.cfm is included in the top of any cfm files without include code.


    coldFusion developers usually put logic rather than display in the file of application.cfm

    In my experience, it is very useful.

    How about PHP?

  2. #2
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So then swap the logic the other way around?
    Instead of having each file include the header... that's how people build frameworks

  3. #3
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    You could look at the auto_prepend_file ini setting for PHP, but that'll apply automatically prepend the file to all php files in your website (not just in the root).

    http://php.net/manual/en/ini.core.php

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dotJoon View Post
    I have the header.php which has the basic logic applying to all php files inside web root folder.

    Let's suppose I have the following 5 pages "index.php, post.php, list.page, read.page, update.page" in the folder.

    Index.php begins with <?php include "header.php" ?> .
    post.php begins with <?php include "header.php" ?> .
    list.php begins with <?php include "header.php" ?> .
    read.php begins with <?php include "header.php" ?> .
    update.php begins with <?php include "header.php" ?> .

    All php files in the folder begins with <?php include "header.php" ?> .

    I doubt why I should put the code "<?php include "header.php" ?>" in all php files in the folder.
    I'll be happy if all php files in the folder has the code of header.php automatically without the code <?php include "header.php" ?>.


    coldFusion has this kind of function.
    The file of the name is "application.cfm"

    When a user open any coldFusion(cfm) files in a folder,
    coldFusion server searchs application.cfm in the folder before it reads the requested cfm files.

    If application.cfm is in the folder, it reads application.cfm first and reads the requested cfm file.

    If application.cfm is not in the folder, it reads the requested cfm file.

    If a user calls application.cfm directly, it causes error.

    Application.cfm is not a url file.
    Application.cfm is included in the top of any cfm files without include code.


    coldFusion developers usually put logic rather than display in the file of application.cfm

    In my experience, it is very useful.

    How about PHP?
    What about having an index.php which includes header.php and then includes the appropriate page file (post.php, list.php etc)?

  5. #5
    SitePoint Zealot
    Join Date
    Jun 2010
    Location
    Arizona
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, that was a nice feature of CF. But you are using PHP now. The change is a nuisance if you are a serious CF developer, but that's what learning a new scripting language entails. Wait until you hit PHP's approach to database access - it'll drive a CF developer like you completely nuts.

    You may want to consider using a CMS (WordPress, Joomla, Drupal, Barebones CMS, etc.) or a framework (Zend, CakePHP, etc).
    Thomas Hruska

    Single Sign-On Server/Client - The PHP login system that rocks.


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
  •