php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8139 NULL and isset
Submitted: 2000-12-06 12:57 UTC Modified: 2000-12-14 05:07 UTC
From: richard dot heyes at heyes-computing dot net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.3pl1 OS: Linux
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: richard dot heyes at heyes-computing dot net
New email:
PHP Version: OS:

 

 [2000-12-06 12:57 UTC] richard dot heyes at heyes-computing dot net
<?php
function foo(&$bar){
    return TRUE;
}

foo($bar);

print($bar);

if(!isset($bar))
    print('Bar is not set!');
?>

With notices turned on (error_reporting) the call to print($bar) does not throw an error. However the bit below it runs the print() call. So if it's not set, the first print should throw an error regarding the unset $bar. Seems very contradictory. FWIW the type of $bar after the call to foo() is NULL.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-06 13:18 UTC] joey@php.net
The question is: should passing an unset variable by reference
generate a warning?
 [2000-12-07 04:22 UTC] richard dot heyes at heyes-computing dot net
No idea. Though I do know of people who use that method to set variables, so their answer would be a resounding no. :)

(EG:
<?php
function mconnect(&$link){
    $link = mysql_connect();
}

mconnect($db);
?>
)
 [2000-12-14 05:07 UTC] stas@php.net
From current Zend code I see that no operation that should
write variable (including passing by reference) won't
generate "undefined" waring. This seems logical - if you
write it, why you care if it wasn't set before?

So I'd close it, since it's not a bug, but intended
behaviour. If you disagree, submit a feature request.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Jul 11 23:00:01 2026 UTC