Code Library: PHP

put in PHP files; E.g if(date('l')=='Monday') print 'Oh no it's Monday!';

PHP  Description Result

PHP can be added to your top.inc, header.php, footer.php and foot.inc files. (Put snippets in your top.inc file.)

These examples show you how you can add your own php code. This first example provides the correct phone prefix depending on the users country.

Phone us on: <?
if($_SESSION[country_id]=='121') print '(09)'; else print '0064 9';
?>
555 2458

Phone us on: 0064 9 555 2458

In this example someone has linked to your website with an incorrect or obsolete URL: www.yourwebsite.co.nz/homepage.html

While there are other ways you can set redirects, you can edit the top.inc file and set up a redirect:

<?
if($_SERVER[REQUEST_URI]=='/homepage.html') {
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: /" );
exit;
}
?>

For all PHP files go to /vendo/php/

The page will redirect user to the homepage.

Load order for PHP files

PHP files are included and loaded in the following order (your files are in bold):

  1. System global
  2. top.inc loaded before headers
  3. System header including <html> <head> and <body> tags and CSS and JS files in the <html> <head>
  4. header.html your template header
  5. head.inc your php head file
  6. System page content beginning with h1 tag and system messages
  7. foot.inc your php foot file
  8. footer.html your template footer
  9. System footer including closing html </body> and </html> tags
  10. bottom.inc your final php file
×