Re: php5 methode + num parameters

From: Date: Mon, 07 Jul 2003 17:39:05 +0000
Subject: Re: php5 methode + num parameters
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-154211@lists.php.net to get a copy of this message
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


« previous php.general (#154211) next »