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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 15:01:33 2024 UTC