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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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: Thu May 02 08:01:32 2024 UTC