Location: PHPKode > scripts > Type Hint Class > type-hint-class/example.php
<?php
/**
 * @ignore
 */

/**
 * @ignore
 */

require_once 'typehintclass.lib.php';

function exampleString(string $string) {
    echo "'$string' is a string!\n";
}
/**
 * @ignore
 */
class foo {
    function __toString() {
        return "foo!";
    }
}
function exampleInt(int $int) {
    echo "$int is an int!\n";
}
function exampleFloat(float $float) {
    echo "$float is a float!\n";
}
function exampleBool(bool $bool) {
    var_export($bool);
    echo " is a bool!\n";
}

exampleString("Hello World!");
exampleString(1);
exampleString(1.2);
exampleString(new foo);

exampleInt(1);
exampleInt("2");

exampleFloat(1);
exampleFloat(1.2);
exampleFloat("2");
exampleFloat("2.3");

exampleBool(false);
exampleBool(true);
?>
Return current item: Type Hint Class