Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP Question

Options
  • 20-01-2011 3:14pm
    #1
    Closed Accounts Posts: 2,828 ✭✭✭


    What is the best practice for including common static website elements such as header, navigation and footer in PHP?

    Would I use a require_once and link to seperate files like, header.php, nav.php etc..

    Or would I be best off doing something like this
    [definitions.php]
    
    define('HEADER','');
    define('NAVIGATION','');
    define('FOOTER','');
    
    [index.php]
    
    require_once('definitions.php');
    
    echo HEADER;
    echo NAVIGATION;
    
    ....
    
    
    echo FOOTER;
    
    


Comments

  • Registered Users Posts: 8,488 ✭✭✭Goodshape


    I think the definitions method is a bit messy. And means you're mixing HTML output in with your PHP definitions file.

    Create the header.php and footer.php and use <?php include('header.php'); ?>.


  • Closed Accounts Posts: 2,828 ✭✭✭Reamer Fanny


    Will do cheers :D


Advertisement