开发者

php null is undefined value? [duplicate]

开发者 https://www.devze.com 2023-04-07 09:05 出处:网络
This question already has answers here: Closed 10 years ago. Possible Duplicate: PHP: “Notice: Undef开发者_运维知识库ined variable”and “Notice: Undefined index”
This question already has answers here: Closed 10 years ago.

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;

0

精彩评论

暂无评论...
验证码 换一张
取 消