Skip to content
WJunction - Webmaster Forum

Advanced PHP (Registry System) - Guide/Tutorial

Status
Not open for further replies.

21 comments

Really nice one Litewarez, I just don't like your indentation style lol, otherwise your code is super. Anyway, I have a question how does the getter and setter magic method work?
 
The Getter and Setter magic method basically lets you add stuff into the class without needing to create a function and predefined variables

so for instance

PHP:
<?php
class Dman{
    function __get($var){
        echo $var;
    }
}
$Dman = new Dman;

//no if i do this
$Dman->I_Love_Litewarez; // this would echo I_Love_Litewarez

//What happens is because the variable "var $I_Lovae_Litewarez" is not there it will send the variable name to __get() and try let the function create some data for that
?>

No the same is with the __set(); it takes 2 variables a $key and a $varaible and in the function you can pull stuff from an array or summat..

It basically allows you to set data like $Dman->someVariableKey = "Some VariableValue";
 
Status
Not open for further replies.

About the author

L
Active Member · Joined
I am a skilled programmer within PHP,HTML,CSS,MYSQL and also the owner of several websites Programming, Football...
1,367
Messages
1
Reactions
38
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom