blob: 1f946d9794c305364dd8a27e4bf828cbf1430c03 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
--TEST--
SPL: spl_autoload() with methods
--SKIPIF--
<?php if (!extension_loaded("spl")) print "skip"; ?>
--INI--
include_path=.
--FILE--
<?php
class MyAutoLoader {
function autoLoad($className)
{
echo __METHOD__ . "($className)\n";
}
function autoThrow($className)
{
echo __METHOD__ . "($className)\n";
throw new Exception("Unavailable");
}
}
try
{
spl_autoload_register(array('MyAutoLoader', 'autoLoad'), true);
}
catch(Exception $e)
{
echo 'Exception: ' . $e->getMessage() . "\n";
}
// and
$myAutoLoader = new MyAutoLoader();
spl_autoload_register(array($myAutoLoader, 'autoLoad'));
spl_autoload_register(array($myAutoLoader, 'autoThrow'));
try
{
var_dump(class_exists("TestClass", true));
}
catch(Exception $e)
{
echo 'Exception: ' . $e->getMessage() . "\n";
}
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
Exception: Passed array specifies a non static method but no object
MyAutoLoader::autoLoad(TestClass)
MyAutoLoader::autoThrow(TestClass)
Exception: Unavailable
===DONE===
|