PHP Object Oriented Programming

PHP is an object oriented scripting language. Here are the terms related to object oriented programming:

You will learn all about the above listed object oriented concept available in PHP programming step by step devided into separate tutorials. For now let's take example on object oriented programming in PHP.

PHP Object Oriented Programming Example

Here is an example on object oriented concept in PHP.

<!DOCTYPE html>
   <title>Object Oriented Programming in PHP</title>
<h3>Object Oriented Programming Example in PHP</h3>
   // This example is based on object oriented concept
   // available in PHP - CodesCracker
   class oop_class
      public $oop_member_var = "oop_member_var member variable";
      public $oop_function_name = "oop_member_function";
   function oop_member_fun()
      echo "Inside oop_member_fun()";
   $oop_class = new oop_class;
   // to access member variables in an object,
   // you can use another variable as name 
   // as shown here
   $element = "oop_member_var";
   echo $oop_class->$element;

Here is the sample output produced by the above object oriented example code in PHP.

php object oriented

PHP Online Test

« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook

Subscribe Us on YouTube