<?php
/*
(PHP 5 >= 5.1.2, PHP 7)
php延迟加载
*/
function my_load($class)
{
require($class.'.php');
}
spl_autoload_register('my_load');
$is_girl=$_GET['sex'] == 0 ? true : false;
if($is_girl)
{
echo '<h1>this is a girl</h1>';
$test1 = new Test1;
}else{
echo '<h1>this is a boy</h1>';
$test2 = new Test2;
}
?>
网友评论