Create a class with a single method in PHP

Description

The following code shows how to create a class with a single method.

Example


/*from   ww  w.  j a  v  a  2s .  c  o m*/
<?php
  class Example
  {
    var $value = "some value";

    function PrintValue()
    {
      print $this->value;
    }
  }

  $obj = new Example();
  $obj->PrintValue();
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Language Basic »




PHP Introduction
PHP Operators
PHP Statements
Variable
PHP Function Create
Exception
PHP Class Definition