xref: /PHP-7.2/ext/spl/tests/spl_autoload_003.phpt (revision 610c7fbe)
1--TEST--
2SPL: spl_autoload() and friends
3--INI--
4include_path=.
5--FILE--
6<?php
7
8function TestFunc1($classname)
9{
10	echo __METHOD__ . "($classname)\n";
11}
12
13function TestFunc2($classname)
14{
15	echo __METHOD__ . "($classname)\n";
16	throw new Exception("Class $classname missing");
17}
18
19function TestFunc3($classname)
20{
21	echo __METHOD__ . "($classname)\n";
22}
23
24spl_autoload_register("TestFunc1");
25spl_autoload_register("TestFunc2");
26spl_autoload_register("TestFunc3");
27
28try
29{
30	var_dump(class_exists("TestClass", true));
31}
32catch(Exception $e)
33{
34	echo 'Exception: ' . $e->getMessage() . "\n";
35}
36
37?>
38===DONE===
39<?php exit(0); ?>
40--EXPECTF--
41TestFunc1(TestClass)
42TestFunc2(TestClass)
43TestFunc3(TestClass)
44Exception: Class TestClass missing
45===DONE===
46