Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php class instance

<?php
// Create the class first...
class Person
{
    public $name;
    public $surname;
    
    function __construct($name, $surname)
    {
    	$this->name = $name;
        $this->surname = $surname;
    }
    
    function getName()
    {
    	return $this->name;
    }
    
    function getSurname()
    {
    	return $this->surname;
    }
    
    function setName($value)
    {
    	$this->name = $value;
    }
    
    function setSurname($value)
    {
    	$this->surname = $value;
    }
}

// Now, you can create an instance of the class
$me = New Person("John", "Doe");
echo $me->getName();
$me.setName("Jane");
echo $me->getName();

/**
   I hope that this helps ^_^ 
 **/
?>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #class #instance
ADD COMMENT
Topic
Name
4+1 =