php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #18223 Extended ease of if () / elseif () and is_null() bug (?)
Submitted: 2002-07-08 07:41 UTC Modified: 2003-04-26 09:38 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: GrimZ at php-freaks dot org Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.2.1 OS: Windows 2k / Linux / FreeBSD
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: GrimZ at php-freaks dot org
New email:
PHP Version: OS:

 

 [2002-07-08 07:41 UTC] GrimZ at php-freaks dot org
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-26 09:38 UTC] helly@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Solve this with php. No support will be done ever at language level.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 14:01:31 2025 UTC