PHP objects & properties

PHP objects & properties

Every class in PHP must have new instances or object created. This object must be assigned to a variable. An object will always be assigned when creating a new object unless the object has a constructor defined that throws an exception on error

Example:
<?php
$instance = new sample();
?>

For accessing an objects property and In order to perform a method within an object; one needs to specify both the object name and the function name:

$result = $instance->setsample('value');
PHP access control modifier
Access control modifiers restrict the functions and classes to be accessed.
PHP constructors & destructors
Constructor methods for classes can be declared. Classes having a constructor method can call this method on each new object.
PHP GET & POST
PHP’s $_GET variable is used to collect names and data from a form using the method GET.
Post your comment