Showing posts with label Property and methods php. Show all posts
Showing posts with label Property and methods php. Show all posts

Wednesday, July 20, 2011

Object Oriented PHP

This section will make a spark on object oriented progrming in php . I will proceed through examples.Just follow yhe exaples and try to do by self. Hope you know basic php programing.

           First create to files(empty)
               1) index.php
               2)class_lib.php

Dont get excited on the "class_lib.php" , I will explain it later.


  • we will write the whole classes within the "class_lib.php" file
  • insert these code with include or require.

Example 1 :  Simple php class

                    <?php
                    
                          class Person {
                           
                          }
                    ?>

Note : I will use and modify the above code in precieding examples

Example 2 :  Adding property

                   <?
                        
                      class Person {

                          var $name;
                     }

                  ?>

Note : "var $name" is called property . Means specifying variable name inside a class .