php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15555 Extra null parameter appearing with func_get_args
Submitted: 2002-02-14 11:25 UTC Modified: 2002-07-05 15:19 UTC
From: lindsay dot marshall at ncl dot ac dot uk Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.1.0 OS: Redhat 7.2
Private report: No CVE-ID: None
 [2002-02-14 11:25 UTC] lindsay dot marshall at ncl dot ac dot uk
I have a function that takes a variable number of arguments and uses func_get_args to retrieve them as an array. In  one place when I call this function with two arguments a third, empty argument is added. As the function is used to generate SQL 'where' clauses by joing strings with ' and ', this caused a sever problem to my system!  I have added an explicit test for null strings in the function and this has worked round the problem.  I use this function in many places in my code and only this one call has problems. Here is the function, you can see the work round code I added.

    function dband()
    {
             $args = func_get_args();
           $str = jval(array_shift($args));
	         foreach ($args as $v)
	         {
 #        	    if ($v != '')
 #       	    { 
	                  $str .= ' and '.jval($v); 
	#            }
	      }
     	return $str;
    }

I had another version of this function that tried to use array functions to achieve this result but I could not get it to work reliably, but for reasons other than extra arguments.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-05 15:19 UTC] sniper@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately your are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

And if it still doesn't work with 4.2.1, please 
give us a short but complete example which shows
clearly what the rproblem is.

(complete script being one that can be easily copied/pasted and run in command line)

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 26 16:01:30 2024 UTC