note 55131 added to function.func-get-args

From: Date: Tue, 26 Jul 2005 12:07:04 +0000
Subject: note 55131 added to function.func-get-args
Groups: php.notes 
Request: Send a blank email to php-notes+get-92464@lists.php.net to get a copy of this message
It doesn't appear in the notes for func_get_args(), but this function will return FALSE when no arguments have been passed. Therefore, you can use a function like this: function test() { echo '<h1>Did this work?</h1>'; if ($array = func_get_args()) { echo '<h1>SUCCESS!</h1>'; } } // Prints <h1>SUCCESS!</h1> test(1,2,3,4); // Doesn't print <h1>SUCCESS!</h1> test(); Testing for the arguments becomes a matter of pulling them. Unless one really have a need for func_num_args(), testing for FALSE should suffice most of us. ---- Manual Page -- http://www.php.net/manual/en/function.func-get-args.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55131 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55131&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55131&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55131&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55131&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55131&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55131&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55131&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#92464) next »