codescracker
php

PHP Member Variable



« Previous Tutorial Next Tutorial »

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>
<html>
<head>
   <title>Member Variable Example in PHP</title>
</head>
<body>
<?php
   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;
?>
</body>
</html>

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 »



© Copyright 2021. All Rights Reserved.

CodesCracker