PHP/Utility Function/require
require() operates like include(), including a template.
It has this syntax: require(file insertion_file)
The insertion_file will be included in the script.
// A sample file to be inserted (init.tpl)
<?
$site_title = "PHP";
$contact_email = "w@hotmail.ru";
$contact_name = "Sales";
?>
//Making use of init.tpl
<? require ("init.tpl"); ?>
Using require to Load Files in PHP
//File: library.inc
<?
function is_leapyear($year = 2004) {
$is_leap = (!($year % 4) && (($year % 100) || !($year % 400)));
return $is_leap;
}
?>
<?php
require ("library.inc"); // Parentheses are optional
$leap = is_leapyear(2003);
?>