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 Ralf Mike Pretzlaw  >  Overload  >  Example.php  >  Download  
File: Example.php
Role: Example script
Content type: text/plain
Description: Example for overloading an object in PHP with some does and dont's
Class: Overload
Emulate class function overloading
Author: By
Last change: Missed semicolon
Date: 5 years ago
Size: 651 bytes
 

Contents

Class file image Download
<?php
include("Overload.class.php");

class 
Example extends Overload
{
    protected function 
foo()
    {
        return 
NULL;
    }
      
    protected function 
foo_S($string)
    {
        echo 
$string;
    }
      
    protected function 
foo_SI($string$integer)
    {
        echo 
$string " equals " $integer ".";
    }
}
  
$o = new Example();
$o->foo();                    // Will call foo()
$o->foo("Hello World!");     // Will call foo_S("Hello World!")
$o->foo("Pi"3);            // Will call foo_SI("Pi", 3)
$o->foo(3"Pi");            // Will lead to an error because there is no function with foo_IS
$o->foo($o1);              // Will lead to an error because there is no function with foo_OI
?>