Q:

Set variables in a class

I wanna do something like this:
<?php
    $editor = new editor('reply.php?topic=100', 'simple');
    echo $editor;
?>

But im not fammilliar with OOP / Classes, but i wanna do something like this in the class:
<?php
class editor($url, $type)
{
    if($type == 'simple'){
        ?>
            <form action="<?php echo $url; ?>">
                ...
            </form>
        <?php
    }
    else
    {
        ...
    }
}
?>

Ofcourse, this isn't right. But how can i make it? Because i don't understand anything about constructors and destructors etc...

A:

$editor = new editor('reply.php?topic=100', 'simple');
echo $editor;

class editor
{
    private $url;
    private $type;

    public function __construct($url, $type)
    {
        $this->url = $url;
        $this->type = $type;
    }

    public function __toString()
    {
        if($this->type == 'simple'){
            return '<form action="' . $this->url . '"></form>';
        } else {
            return 'foobar';
        }
    }
}

