PHP/Reflection/gettype

Материал из Web эксперт
Перейти к: навигация, поиск

Creating an object from the Cat class

 
<?php
class Cat {
}
$fluffy = new Cat(  );
echo gettype($fluffy);
?>



Displaying the Type of a Variable

 
<html>
<body>
<div>
<?php
    $testing; // declare without assigning
    print gettype( $testing ); 
    print "<br />";
    $testing = 5;
    print gettype( $testing ); 
    print "<br />";
    $testing = "five";
    print gettype( $testing ); 
    print "<br />";
    $testing = 5.0;
    print gettype( $testing ); 
    print "<br />";
    $testing = true;
    print gettype( $testing ); 
    print "<br />";
?>
</div>
</body>