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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP Question

  • 20-01-2011 2: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, Registered Users 2 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