PHP/Utility Function/require — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 10:37, 26 мая 2010
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);
?>