| 1 2 3+ _+ N) u; k- J: _# [7 F 4 5, ^+ Y0 R+ K; d8 q7 x% \ 6 7 8 90 a4 j8 T! ` C/ v* Q; w 10 11 12. r& n. ?& I5 B 13 14 15- d; t2 R% R$ l+ g+ r 16 17 184 [- l) {1 _ _+ U( Z 19$ l" A* K. M) g0 o. Q( Z% C 20 21 22 23 24 25 u9 X. A' M5 r( O1 T 26! j4 W- v8 \# T 27; P: V1 A8 `. \ 284 l* @4 s# ?8 S3 t, R- H5 n, ^ 29 30" p$ V& ~( u4 @. g* k 31, F3 B% y! H. ^ 32) e) J; v5 c/ b! r3 i3 y% V3 Q 33 345 l: U% O- x$ f$ s+ {, y 35 36 37 38 39 407 j+ D3 W! g W5 @8 v6 w 41 42% n" P3 k1 s9 Q2 J% x 437 p5 J+ g; X1 A0 U' ^0 j6 ] 44( `$ {) z+ C( w0 d8 y1 Y! [ 45 46 47 48 l& ?, ?5 D B$ W: T 49 50 517 q$ M H1 j# S4 w 524 t; U$ g/ n: k \+ ^6 u 53# j o I; m) y+ i6 [4 k" O' ^ 54 55+ e- ?$ P. j& L( S$ N; m 56 | <?php class inload+ M* H" |! d, P, o {" `, x8 I$ p- i& v% x /** * 类自动载入,不需要由开发者调用( B; I0 a' y0 i- v * * @param string $class 类文件/ V& @5 l3 ]2 h) ]3 w */7 L5 ?! Z7 Z0 N/ i# C4 D- t, A* X3 G private function autoload( $class )* e( B, f/ G2 }& V; ?! U }# _! W/ X {1 S3 K7 w9 K& O5 y' D1 O if( empty($class) ). s! K# e r% p- u* C" D { throw new qexception('加载文件不存在'.$class); }) t3 B: q: V* G& ?! X" b& h S$ B9 k else { require _spring_.'/_core/springmap.php'; //框架地图, j4 ?' \" S. T) p7 @6 d if(! file_exists( $source[$class]['file'] ) )8 m1 d9 m6 ^5 ^* y4 y" y I {6 @% ]7 ]- k- d! a7 O" M throw new qexception('加载文件不存在'.$class);/ O% c* d' f4 b) w7 x. Q/ ~: z& l }" l" G1 H1 w$ k: ~- v require $source[$class]['file'];8 l) |) v6 Q9 J0 M. j8 i# N } }; h- d2 Y) C# {5 t 5 V% T) Y! _" I8 f' B2 d /**; f( M+ I& ~" p) y0 l * 注册或取消注册一个自动类载入方法0 l+ q9 c+ u. J+ e1 e * * 该方法参考 zend framework * * @param string $class 提供自动载入服务的类 * @param boolean $enabled 启用或禁用该服务/ s1 ?, k1 m: ?% G* g$ Y2 L */ private function registerautoload($class = 'interpreter' , $enabled = true) {( J9 a1 J) w1 i7 o1 B" N7 Z- j+ q if (!function_exists('spl_autoload_register')), a# v* e) u5 d% Z. k) { E# @1 I' S { throw new qexception('spl_autoload 不存在这个php的安装'); } if ($enabled === true) { spl_autoload_register(array($class, 'autoload')); } else% P" c- ~. x9 K8 V {0 o/ _' g N( ?/ s3 ~ spl_autoload_unregister(array($class, 'autoload')); }" s: T' D1 q7 w3 [( q }# o2 t* _; X3 l( N$ ` /** * 析构函数 */ public function __destruct(): M4 l1 P% F/ h" Y% Y! x {, \* q+ A$ B) N% ]0 c self::registerautoload('interpreter' , false); } |
| 欢迎光临 得知互动 (https://bbs.dezhifl.com/) | Powered by Discuz! X3.5 |