abstract:<?php //自动加载器:最重要的一个参数就是一个回调 spl_autoload_register(function($className){ //推荐使用绝对路径 include __DIR__.'\..\chapter_04\public\\'.$className
<?php //自动加载器:最重要的一个参数就是一个回调 spl_autoload_register(function($className){ //推荐使用绝对路径 include __DIR__.'\..\chapter_04\public\\'.$className.'.php'; }); $mobile=new Mobile('华为','P20','7200'); echo $mobile->brand.$mobile->model.':'.$mobile->price,'<br>';
Correcting teacher:天蓬老师Correction time:2019-04-14 21:11:20
Teacher's summary:当脚本 中的引用的外部类较多时, 大量的include会影响到代码的执行效率,都过自动加载, 可以极大的方便用户