|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-05-25 16:59 UTC] meebey@php.net
When I pass 3 parameters to an user PHP function, that needs 2 parameters, I don't get any fatal, warning nor notice.. The function is just called and the 3. parameter ignored...
When C PHP Functions are called like mysql_connect() with a wrong parameter count, I will get a E_WARNING. It should be the same with the user functions...
ZEND_API void zend_wrong_param_count(TSRMLS_D) does this for the C functions...
Also it's the same behaviour on ZendEngine2, no fatal, warning nor notice..
here a simple script to reproduces/test the bug:
#!/usr/local/bin/php
<?php
// to be sure we get all fatal, warnings and notices
error_reporting(E_ALL);
ini_set("display_errors","1");
// declaring a function which takes _2_ parameters
function foo($param1, $param2) {
echo "function foo is called, all went fine...\n";
}
// calling the function and passing _3_ parameters
foo(1, 2, 3);
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 13:00:02 2025 UTC |
I think this isn't a bug and there should be no warning. Reason: Users can define functions of variable number of parameters. So you can define a function with no parameters like function foo() { ...} and cal it with a different number of parameters like foo($a,$b); foo($a,$b,$c,$d); To handle them ther are functions like func_num_arg() or func_get_args() So warnings are wrong in that case.