PHP Member Variable

Member variables in PHP are those variables which are defined inside the class.

PHP Member Variable Example

Let's take an example on member variable in PHP.

<!DOCTYPE html>
   <title>Member Variable Example in PHP</title>
   class Myclass 
      // here the variable $member_variable
      // can be called as member variable
      public static $member_variable = "I am in member variable";
   // now create object of above defined class
   $object_Myclass = new Myclass;
   // now access member variable using object of the class
   echo $object_Myclass::$member_variable;

Here is the sample output produced by the above member variable example code in PHP.

php member variable

PHP Online Test

« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook

Subscribe Us on YouTube