php null is undefined value? [duplicate]
Possible Duplicate:
PHP: “Notice: Undef开发者_运维知识库ined variable” and “Notice: Undefined index”
I got error:
Notice: Undefined variable: null
Line in code is:
$input = new $class($company, null, $sablonas, $null, $value);
Class constructor is:
public function __construct($company, $document, $sablonas, $options, $value = null) {
How I can pass a null value?
$input = new $class($company, null, $sablonas, $null, $value);
// ^ ^
// (1) (2)
It's talking about (2)
, not (1)
. You have a typo with $null
.
The notice message "Undefined variable: null" is a little misleading here, but consider the following case:
<?php
error_reporting(E_ALL | E_NOTICE);
echo $lol;
// Output: "Notice: Undefined variable: lol in /t.php on line 3"
?>
You can see that the $
isn't included in the name that the notice message gives you, so if you follow this logic back you arrive at the conclusion I made at the top of this answer.
You have $null
as a variable:
$input = new $class($company, null, $sablonas, $null, $value);
//------------------------------------------^^^^^^^^^^
// Guessing that's supposed to be
$input = new $class($company, null, $sablonas, null, $value);
//-------------------------------------------^^^^^^^^
$null = NULL;
精彩评论