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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
42 + 28 = ?
Subscribe to this entry?

 
 [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 20:01:35 2024 UTC