downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

spl_autoload_extensions> <iterator_to_array
[edit] Last updated: Fri, 25 May 2012

view this page in

spl_autoload_call

(PHP 5 >= 5.1.2)

spl_autoload_call要求されたクラスを読み込むために、すべての登録済みの __autoload() 関数を試す

説明

void spl_autoload_call ( string $class_name )

この関数は、登録済みの __autoload 関数を使用して クラスあるいはインターフェイスを手動で探すために使用することができます。

パラメータ

class_name

探したいクラス名。

返り値

値を返しません。



add a note add a note User Contributed Notes spl_autoload_call
k dot varmark at gmail dot com 02-Feb-2011 12:40
It should be noted, that calling spl_autoload_call on a child class, and then on its parent class, throws a fatal error.

This happens because autoloading the child class also loads the class it extends. And since spl_autoload_call forcibly calls the registered autoload function(s), not taking into account whether the class exists, a fatal error is thrown:

File: child.class.php

<?php
class Child extends Parent () {
    public function
__construct () {
       
parent::__construct();
    }
}
?>

File: parent.class.php

<?php
class Parent () {
    public function
__construct () {

    }
}
?>

File: autoload.php

<?php

/*    works fine    */
   
spl_autoload_call('Child');

/*    throws: Fatal error: Cannot redeclare class Parent in /parent.class.php on line 2    */
   
spl_autoload_call('Parent');

?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites