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
 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 09 11:01:34 2025 UTC