Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Martin Alterisio  >  Type Hint Class  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Type Hint Class
Implement type hinting support for base PHP types
Author: By
Last change: Accessible without user login
Date: 7 years ago
Size: 774 bytes
 

Contents

Class file image Download
<?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);
?>