php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36029 Can not parse NULL as reference
Submitted: 2006-01-16 09:35 UTC Modified: 2006-01-16 10:12 UTC
From: f dot engelhardt at 21torr dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.1.2 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: f dot engelhardt at 21torr dot com
New email:
PHP Version: OS:

 

 [2006-01-16 09:35 UTC] f dot engelhardt at 21torr dot com
Description:
------------
In C and most other programming languages it is possible to parse NULL as a reference parameter to a function (a NULL-Pointer). In PHP i need to allocate a variable, that can be given to the function. So there is no way to parse a NULL-Pointer.

Reproduce code:
---------------
<?php

function bTest(&$paData)
{
  if (is_null($paData))
  {
    // cleanup
    return true;
  }
  // handle data
  return true;
}

bTest(NULL);

?>

Expected result:
----------------
Should work

Actual result:
--------------
Fatal error: Cannot pass parameter 1 by reference in ...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-16 09:45 UTC] sniper@php.net
Yes, but PHP is not C and references are not pointers.
 [2006-01-16 10:12 UTC] derick@php.net
And this works fine:

$foo = NULL;
bTest( $foo );
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 12:01:33 2025 UTC