How can I use variables defined later in the page? PHP -


this how have files setup:

index.php:

    include($sys->root_path.'sections/start.php'); // includes <html>      if (isset($_get['page'])) {       $page = $_get['page'].'.php';     } else {       $page = 'index.php';     }      if (isset($_get['cat'])) {       $cat = $_get['cat'];     } else {       $cat = '';     }      include($sys->root_path.'/content/'.$cat.'/'.$page);      include($sys->root_path.'sections/end.php'); // includes here </html> 

to view page, visit: example.com/index.php?cat=red&page=car show me page content of file at:

/content/red/car.php 

the problem having want specify title, meta description, etc. each page, , outputted page in start.php- before specific data particular page called.

what hoping this:

/content/red/car.php:

<?php $page_title = 'title of page'; ?> <p>everything below page's content...</p> 

how can use page specific data in <head> of site, when data grabbed before contents of specific page?

you like:

switch($_get['page']) {     case 'car':         // here have conditional category.         $page_title = 'title of page';         break;     // other cases. } include($sys->root_path.'sections/start.php'); 

and in start.php have like:

<title><?php echo $page_title; ?></title> 

i must advise against way of including content. insecure. browse server files or include don't want included. 1 should never include files way (through variables) unless 1 filter variable through regular expression or else.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -