Hi Yann,

In my experience, PHP 4 only complains if you pass in too few arguments, not too many.

If you would like an exception, you could try

class MyException extends Exception
{
    private $_msg;
    function __construct($msg = '';)
    {
        $this->_msg = $msg;
    }

    public function showError()
    {
        return 'ERROR ' . $this->_msg;
    }
}

class FormElement {
... // variable declarations

private function SetStyle($element_style)
{
    if (func_num_args() > 1)
    {
        throw(new MyException('too many arguments'));
    }
    ... // normal code here
}
}

Regards,
Greg
--
phpDocumentor
http://www.phpdoc.org

Yann Larrivee wrote:
Hi i have the fallowing code (simplified)

class FormElement {
private $element_id = null;
private $element_name = null;
private $element_type = null;
private $element_style = null;
private $element_string = null;


public function FormElement($properties) { $this->SetStyle($properties["default_style"],$properties["error_style"]); }

private function SetStyle($element_style)
{
    $this->element_style = $element_style;
}

}



Avisouly i pass it 2 parameters  and it is expecting only 1.
Usually PHP Bugs when this kind of thing happen right ? (php 4 anyways)
But not in PHP5 it seems.

Anybody else has experienced this problem ?

Thanks




-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to