kelas instance php dari string
$class = '\Foo\Bar\MyClass';
$instance = new $class();
Tiago F2
$class = '\Foo\Bar\MyClass';
$instance = new $class();
<?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 ^_^
**/
?>