php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47363 for($i=4;$i<((func_num_args() + sizeof($array)));$i++) does not work.
Submitted: 2009-02-12 04:15 UTC Modified: 2009-02-12 14:52 UTC
From: devilx at devilx dot net Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.2.9RC1 OS: Linux, Mac OS X
Private report: No CVE-ID: None
 [2009-02-12 04:15 UTC] devilx at devilx dot net
Description:
------------
The Calculation of sizeof + func_num_args within a for does not work / 
ends in an endless-for.

Reproduce code:
---------------
f("this","is","a","test");

function f()
{
   $wuergs = array (
        0 => "1234",
        1 => "B",
        2 => "C",
        3 => "D"
    );

	$args=func_get_args();
	for($i=4;$i<((func_num_args() + sizeof($wuergs)));$i++)
	{
        	$wuergs[$i]=$args[$i-4];
    	}
	return l_backend($wuergs);
}

Expected result:
----------------
Moving the content of $args four arrays highr.

Actual result:
--------------
Endless loop.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-12 14:33 UTC] smlerman at gmail dot com
Try checking the value of sizeof($wuergs) inside the loop. Hint: it changes every time.
 [2009-02-12 14:52 UTC] scottmac@php.net
The condition is evaluated at the start of each iteration.

Also moving the calculation above the loop works.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Dec 05 19:00:01 2025 UTC