javascript - How to change the content of a default page layout in PHP -
i have php webpage designed layout below. saved default.php
, intended imported page layout pages in website. content in 'section a' , 'section b' same pages want alter content of 'section c' each page. how do this?
i know can utilize "content place holder" in .net framework, how do in php? new php - help appreciated.
+------------------------------+ | section | |-----+------------------------| | | | | | | | | | | b | section c | | | | | | | +-----+------------------------+
as per comment, if including default.php using require, need swap content in default.php variable, set variable before require default.php.
as example:
//index.php $page = isset($_get['p'])? $_get['p'] : 'home'; $pages = ['home','about','contact']; $include = in_array($page, $pages) ? $page . '.php' : 'error.php'; require_once('default.php'); //default.php <html> <head></head> <body> <div class="header"> <h1>page header</h1> </div> <div class="leftcol"> <p>left column contents</p> </div> <div class="main"> <?php include($include);?> </div> </body> </html>
you access different pages so:
example.com/ //would show homepage example.com/?p=about //would show page example.com/?p=blahfff //would show error page
javascript php css
No comments:
Post a Comment