CLASS_ALIAS(3) 1 CLASS_ALIAS(3)class_alias - Creates an alias for a classSYNOPSIS
bool class_alias TRUE (string $original, string $alias, [bool $autoload])
DESCRIPTION
Creates an alias named $alias based on the user defined class $original. The aliased class is exactly the same as the original class.
PARAMETERS
o $original
- The original class.
o $alias
- The alias name for the class.
o $autoload
- Whether to autoload if the original class is not found.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
class_alias(3) example
<?php
class foo { }
class_alias('foo', 'bar');
$a = new foo;
$b = new bar;
// the objects are the same
var_dump($a == $b, $a === $b);
var_dump($a instanceof $b);
// the classes are the same
var_dump($a instanceof foo);
var_dump($a instanceof bar);
var_dump($b instanceof foo);
var_dump($b instanceof bar);
?>
The above example will output:
bool(true)
bool(false)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
SEE ALSO get_parent_class(3), is_subclass_of(3).
PHP Documentation Group CLASS_ALIAS(3)
Check Out this Related Man Page
IS_A(3) 1 IS_A(3)is_a - Checks if the object is of this class or has this class as one of its parentsSYNOPSIS
bool is_a FALSE (object $object, string $class_name, [bool $allow_string])
DESCRIPTION
Checks if the given $object is of this class or has this class as one of its parents.
PARAMETERS
o $object
- The tested object
o $class_name
- The class name
o $allow_string
- If this parameter set to FALSE, string class name as $object is not allowed. This also prevents from calling autoloader if the
class doesn't exist.
RETURN VALUES
Returns TRUE if the object is of this class or has this class as one of its parents, FALSE otherwise.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.3.9 | |
| | |
| | Added $allow_string parameter |
| | |
| 5.3.0 | |
| | |
| | This function is no longer deprecated, and will |
| | therefore no longer throw E_STRICT warnings. |
| | |
| 5.0.0 | |
| | |
| | This function became deprecated in favour of the |
| | instanceof operator. Calling this function will |
| | result in an E_STRICT warning. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
is_a(3) example
<?php
// define a class
class WidgetFactory
{
var $oink = 'moo';
}
// create a new object
$WF = new WidgetFactory();
if (is_a($WF, 'WidgetFactory')) {
echo "yes, $WF is still a WidgetFactory
";
}
?>
Example #2
Using the instanceof operator in PHP 5
<?php
if ($WF instanceof WidgetFactory) {
echo 'Yes, $WF is a WidgetFactory';
}
?>
SEE ALSO get_class(3), get_parent_class(3), is_subclass_of(3).
PHP Documentation Group IS_A(3)
when we invoke a line we write
alias aliasname " "
but i have on the original line "specific string" so it must be
alias aliasname " "specific string" "
and it cause me trouble what can i do ? (5 Replies)
Hi:
there is a shell script, with the name "foo", located in a bin directory. in the same time, there is an alias "foo='/path/bin/foo' ", just for convenience.
in my home directory, there is a different script with name "foo" too. (a modified version.)
while in my home directory, when I... (3 Replies)