PHP Classes
elePHPant
Icontem

File: test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of goo  >  FCache  >  test.php  >  Download  
File: test.php
Role: Example script
Content type: text/plain
Description: test file
Class: FCache
Cache the output or returned value of a function
Author: By
Last change:
Date: 1 year ago
Size: 2,925 bytes
 

Contents

Class file image Download
<?php
session_start
();
error_reporting(E_ALL);
ini_set('display_errors', 'On');

require_once(
'FCache.php');

$FCache = new FCache();

/************************ TEST captureScreen () ************************/

function test1($name) {
    echo
'hello '. $name .'.';
    return
true;
}

$result = $FCache->captureScreen(60, 'test1', 'Bakyt');
echo
'<br/>a1) test captureScreen: '. $result .'<br/>';

$result = $FCache->captureScreen(60, 'test1', '123');
echo
'<br/>a2) test captureScreen: '. $result .'<br/>';

$result = $FCache->captureScreen(60, 'test1', 123);
echo
'<br/>a3) test captureScreen: '. $result .'<br/>';

$result = $FCache->captureScreen(60, 'test1', 123.456);
echo
'<br/>a4) test captureScreen: '. $result .'<br/>';

$result = $FCache->captureScreen(60, 'test1', 'Dilan');
echo
'<br/>a5) test captureScreen: '. $result .'<br/>';

$result = $FCache->captureScreen(60, array('TestClass', 'echoHello'));
echo
'<br/>a6) test captureScreen object::static_method: '. $result .'<br/>';

$result = $FCache->captureScreen(60, 'TestClass::echoHello');
echo
'<br/>a7) test captureScreen object::static_method: '. $result .'<br/>';


/************************ TEST captureReturn () ************************/

$result = $FCache->captureReturn(60, 'test_text');
echo
'<br/>b1) test captureReturn: '. $result .'<br/>';

$result = $FCache->captureReturn(60, 'test_var', 'Hi');
echo
'<br/>b2) test captureReturn: '. $result .'<br/>';

$result = $FCache->captureReturn(60, 'test_var', 123);
echo
'<br/>b3) test captureReturn: '. $result .'<br/>';

$result = $FCache->captureReturn(60, 'test_var', 123.456);
echo
'<br/>b4) test captureReturn: '. $result .'<br/>';

$result = $FCache->captureReturn(60, 'test_array');
echo
'<br/>b5) test captureReturn: <br/>';
var_dump($result);
echo
'<br/><br/>';

$result = $FCache->captureReturn(60, 'test_object');
echo
'b6) test captureReturn: '. $result->sayHi() .'<br/>';
var_dump($result);

$TestOjb = new TestOjb();
$result = $FCache->captureReturn(60, array($TestOjb, 'sayHi'));
echo
'<br/>b7) test captureReturn object->method: '. $result .'<br/>';

$result = $FCache->captureReturn(60, array('TestClass', 'sayHello'));
echo
'<br/>b8) test captureReturn object::static_method: '. $result .'<br/>';

$result = $FCache->captureReturn(60, 'TestClass::sayHello');
echo
'<br/>b9) test captureReturn object::static_method: '. $result .'<br/>';



function
test_text() {
    return
'Hello world!';
}

function
test_var($var) {
    return
'test_var: '. $var;
}

function
test_array() {
    return array(
't', 'e', 's', 't');
}

function
test_object() {
   
$TestOjb = new TestOjb();
    return
$TestOjb; // array('t', 'e', 's', 't')
}

class
TestOjb {
    public function
sayHi() {
        return
'Hi';
    }
}

class
TestClass {
    public static function
sayHello() {
        return
'Hello';
    }

    public static function
echoHello() {
        echo
'Hello';
        return
'done!';
    }
}