Bug #18223: Extended ease of if () / elseif () and is_null() bug (?)
| From: | GrimZ at php-freaks dot org | Date: | Mon, 08 Jul 2002 11:41:17 +0000 |
| Subject: | Bug #18223: Extended ease of if () / elseif () and is_null() bug (?) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-13506@lists.php.net to get a copy of this message | ||
From: GrimZ@php-freaks.org
Operating system: Windows 2k / Linux / FreeBSD
PHP version: 4.2.1
PHP Bug Type: Feature/Change Request
Bug description: Extended ease of if () / elseif () and is_null() bug (?)
It would be great if there was some method of PHP storing the last matched
if condition. Allow me to demonstrate.
; --- Example
$myarray = array(
'this' => 'test',
'that' => 'fun',
);
if ($myarray['this'] == 'test')
{
echo('The value is '.$myarray['this']);
}
Now, I'm suggesting something like $ifmatch (easy name) and it would work
like so.
$ifmatch retains the first condition of an if () / elseif() that has
matched (it's TRUE) like so:
if ($myarray['this'] == 'test')
{
echo('The value is '.$ifmatch);
}
Where $ifmatch = 'test' (or, $array['this'] if you prefer)
You might wonder what the advantage is? Well, I think it's a lot easier
and more functional to do this:
if ($myarray['this'] == 'test')
{
echo('The value is '.$ifmatch);
}
Then:
if ($myarray['this'] == 'test')
{
echo('The value is '.$myarray['this']);
}
Or:
$blah = $myarray['this'];
if ($blah == 'test')
{
echo('The value is '.$blah);
}
I'm sure a lot of people could find use for this in the future.
Also, I'm not sure if this is a bug or not, but, the Manual says is_null()
handles mixed variables, however, this returns false:
$test = NULL;
$blah = NULL;
echo((is_null($test,$blah) ? 'Yep' : 'Nope'));
This was tested on 2k with the standard Windows lastest version of PHP and
Apache 1.3.x (last stable)
If is_null() can handle only 1 argument, please extend it for infinite
args, I have coded my own routine for this but obviously PHP's internal
would be faster.
Last, but not least, PHP is probably my favorite language, more so then
C/C++, please keep up the good work, it's truely a fantastic language and
you have all done a fantastic job with it (coders, documentation team, web
team) ;-)
Thanks.
--
Edit bug report at http://bugs.php.net/?id=18223&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=18223&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=18223&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=18223&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=18223&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18223&r=support
Expected behavior: http://bugs.php.net/fix.php?id=18223&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18223&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18223&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=18223&r=globals