Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

spl_autoload_unregister

Description

The spl_autoload_unregister of SPL for PHP unregisters the given function as __autoload() implementation.

Syntax

spl_autoload_unregister(
    callable $callback
): bool

Parameters

callback

The autoload function being unregistered.

Return

Returns true on success or false on failure.

Examples

1 · callback

<?

function callback($class)
{
}

$callback = "callback";

spl_autoload_register($callback);

$return = spl_autoload_unregister($callback);

var_export($return);

?>
true

2 · namespace

<?

namespace mynamespace;

class myclass
{
    public static function callback($class)
    {
    }
}

$callback = "mynamespace\myclass::callback";

spl_autoload_register($callback);

$return = spl_autoload_unregister($callback);

var_export($return);

?>
true

3 · namespace

<?

namespace mynamespace;

class myclass
{
    public function __construct()
    {
        $callback = __CLASS__ . "::callback";

        spl_autoload_register($callback);

        $return = spl_autoload_unregister($callback);

        var_export($return);
    }
    public function callback($class)
    {
    }
}

new myclass();

?>
true
HomeMenu