php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6076 NULL is isset in function arguments
Submitted: 2000-08-10 16:04 UTC Modified: 2000-08-10 16:43 UTC
From: php-bugs at bjoernsworld dot de Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0.1pl2 OS:
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php-bugs at bjoernsworld dot de
New email:
PHP Version: OS:

 

 [2000-08-10 16:04 UTC] php-bugs at bjoernsworld dot de
<?php
  function x($a = "foo")
  {
      print $a;
  }
  
  $val = NULL;
  x($val);
?>

This should print out "foo" but it doesnt.

For my understanding this is an inconsequent behaivour. If i have

<?php
  $a = NULL;
  if (isset($a)) print "ok";
?>

"ok" won't be printed. So, if there is no value set, as isset says, there should not be any value set when the value defaults to another value in the functions argument list.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-10 16:43 UTC] stas@php.net
Yes, that's how it should work. Default argument is used only when no argument is given. And isset() check if variable was set. Value to which it was set is not important.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 05:01:31 2024 UTC