Other Overloading Methods
• These methods are automatically called internally when isset() and unset() is called on undeclared data members. The magic method __isset() method receives an argument - the value of which is the name of the variable that the program wants to test if the variable is set or not.
• The magic method __unset() method receives an argument - the value of which is the name of the variable that the program wants to unset.
• In the example above the script creates a new Customer Object. The program assigns a string value to an undeclared variable i.e. $c->name. The undeclared variable is handled by the magic method __set().
• The program ties to check if the undeclared variable i.e., $c->name has been set or not using the PHP method isset(). Since $c->name is an undeclared variable the PHP5 magic method __isset() is invoked that takes the name of the undeclared variable i.e. ‘name’ and checks if the internal array $data[’name’] is set or not.
Class and Object name same
In php it allowed to create the class and object name as same… if both of them contain the same name then after our program will execute and display the correct output.
Static Method
PHP allowed to use the method outside the class those are declared in to the class. To perform this task we supposed to use the keyword “STATIC”.
Self keyword
We can also use the self keyword... much as you use $this. You know that if we are interested to use the class object inside the class then we use $this keyword… Self Keyword works same for static method exist inside the class. To access a static property: - You need to write the class name followed ( ::) followed by the property name
Const Keyword
Class constants are useful whenever you need to define a fixed value or set of configuraration options
• These methods are automatically called internally when isset() and unset() is called on undeclared data members. The magic method __isset() method receives an argument - the value of which is the name of the variable that the program wants to test if the variable is set or not.
• The magic method __unset() method receives an argument - the value of which is the name of the variable that the program wants to unset.
• In the example above the script creates a new Customer Object. The program assigns a string value to an undeclared variable i.e. $c->name. The undeclared variable is handled by the magic method __set().
• The program ties to check if the undeclared variable i.e., $c->name has been set or not using the PHP method isset(). Since $c->name is an undeclared variable the PHP5 magic method __isset() is invoked that takes the name of the undeclared variable i.e. ‘name’ and checks if the internal array $data[’name’] is set or not.
Class and Object name same
In php it allowed to create the class and object name as same… if both of them contain the same name then after our program will execute and display the correct output.
Static Method
PHP allowed to use the method outside the class those are declared in to the class. To perform this task we supposed to use the keyword “STATIC”.
Self keyword
We can also use the self keyword... much as you use $this. You know that if we are interested to use the class object inside the class then we use $this keyword… Self Keyword works same for static method exist inside the class. To access a static property: - You need to write the class name followed ( ::) followed by the property name
Const Keyword
Class constants are useful whenever you need to define a fixed value or set of configuraration options






No comments:
Post a Comment