Welcome to GuardiansWorlds.com
 
 

  User Info Box

Anonymous
3.145.85.212
Nickname:

Password:

Security Code:
Security Code
Type Security Code:


User Stats:
Today: 0
Yesterday: 0
This Month: 0
This Year: 0
Total Users: 117
New Members:
Online Now:
  Guests: 36
3.145.xx.xxx
85.208.xx.xxx
47.128.xx.xxx
18.221.xx.xx
172.71.xxx.xx

  Total Online: 36
Server Time:
Apr 04, 2025
04:24 pm UTC
 

  Modules/Site Links

· Home
· Bible-MM
· Birds-MM
· Car_Show-MM
· Christmas-MM
· Content
· Domaining-MM
· Downloads
· Drugs-MM
· Event Calendar
· FAQ
· Feedback
· Fish-MM
· Gambling_Guide-MM
· Guardians Worlds Chat
· HTML_Manual
· Internet_Traffic_Report
· IP_Tracking Tool
· Journal
· Members List
· Movies-MM
· Music_Sound-MM
· NukeSentinel
· PHP-Nuke_Tools
· PHP_Manual-MM
· PING Tool
· Private Messages
· Recommend Us
· Reptiles-MM
· Search
· SEO_Tools
· Statistics
· Stories Archive
· Submit News
· Surveys
· Top 30
· Topics
· Visitor Mapping System
· Web Links
· Webcams
· Web_Development-MM
· YahooNews
· YahooPool
· Your Account
 

  Categories Menu

· All Categories
· Camaro and Firebird
· FTP Server
· New Camaro
· News
· Online Gaming
 

  Survey

Which is your favorite generation Camaro or Firebird?

1st Gen. 67-69 Camaro
2nd Gen. 70-81 Camaro
3rd Gen. 82-92 Camaro
4th Gen. A 93-97 Camaro
4th Gen. B 98-2002 Camaro
1st Gen. 67-69 Firebird
2nd Gen. 70-81 Firebird
3rd Gen. 82-92 Firebird
4th Gen. A 93-97 Firebird
4th Gen. B 98-2002 Firebird



Results
Polls

Votes: 66
Comments: 0
 

  Cluster Maps

Locations of visitors to this page
 

  Languages

Select Interface Language:

 

 
  Overloading

Overloading

Both method calls and member accesses can be overloaded via the __call, __get and __set methods. These methods will only be triggered when your object or inherited object doesn't contain the member or method you're trying to access. All overloading methods must not be defined as static. In PHP 5.0.x, all overloading methods must be defined as public.

Since PHP 5.1.0 it is also possible to overload the isset() and unset() functions via the __isset and __unset methods respectively.

Member overloading

void __set ( string name, mixed value )

mixed __get ( string name )

bool __isset ( string name )

void __unset ( string name )

Class members can be overloaded to run custom code defined in your class by defining these specially named methods. The $name parameter used is the name of the variable that should be set or retrieved. The __set() method's $value parameter specifies the value that the object should set the $name.

Example 19-20. overloading with __get, __set, __isset and __unset example

<?php
class Setter
{
    
public $n;
    
private $x = array("a" => 1, "b" => 2, "c" => 3);

    
private function __get($nm)
    {
        echo
"Getting [$nm]\n";

        if (isset(
$this->x[$nm])) {
            
$r = $this->x[$nm];
            print
"Returning: $r\n";
            return
$r;
        } else {
            echo
"Nothing!\n";
        }
    }

    
private function __set($nm, $val)
    {
        echo
"Setting [$nm] to $val\n";

        if (isset(
$this->x[$nm])) {
            
$this->x[$nm] = $val;
            echo
"OK!\n";
        } else {
            echo
"Not OK!\n";
        }
    }

    
private function __isset($nm)
    {
        echo
"Checking if $nm is set\n";

        return isset(
$this->x[$nm]);
    }

    
private function __unset($nm)
    {
        echo
"Unsetting $nm\n";

        unset(
$this->x[$nm]);
    }
}

$foo = new Setter();
$foo->n = 1;
$foo->a = 100;
$foo->a++;
$foo->z++;

var_dump(isset($foo->a)); //true
unset($foo->a);
var_dump(isset($foo->a)); //false

// this doesn't pass through the __isset() method
// because 'n' is a public property
var_dump(isset($foo->n));

var_dump($foo);
?>

The above example will output:

Setting [a] to 100
OK!
Getting [a]
Returning: 100
Setting [a] to 101
OK!
Getting [z]
Nothing!
Setting [z] to 1
Not OK!

Checking if a is set
bool(true)
Unsetting a
Checking if a is set
bool(false)
bool(true)

object(Setter)#1 (2) {
  ["n"]=>
  int(1)
  ["x:private"]=>
  array(2) {
    ["b"]=>
    int(2)
    ["c"]=>
    int(3)
  }
}

Method overloading

mixed __call ( string name, array arguments )

Class methods can be overloaded to run custom code defined in your class by defining this specially named method. The $name parameter used is the name as the function name that was requested to be used. The arguments that were passed in the function will be defined as an array in the $arguments parameter. The value returned from the __call() method will be returned to the caller of the method.

Example 19-21. overloading with __call example

<?php
class Caller
{
    
private $x = array(1, 2, 3);

    
private function __call($m, $a)
    {
        print
"Method $m called:\n";
        
var_dump($a);
        return
$this->x;
    }
}

$foo = new Caller();
$a = $foo->test(1, "2", 3.4, true);
var_dump($a);
?>

The above example will output:

Method test called:
array(4) {
    [0]=>
    int(1)
    [1]=>
    string(1) "2"
    [2]=>
    float(3.4)
    [3]=>
    bool(true)
}
array(3) {
    [0]=>
    int(1)
    [1]=>
    int(2)
    [2]=>
    int(3)
}
 
 


 
  Disipal DesignsAnti-Spam
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest © 2002 by me.
You can syndicate our news using the file backend.php or ultramode.txt This site contains info,links,chat,message board/forum for online games,gaming,other features.Check out my servers and stats for Killing Floor, Quake3 Rocket Arenas & Deathmatch,Trade Wars 2002 & FTP server.Camaro/Firebirds, car info.