0

Possible Duplicate:
PHP: “Notice: Undefined 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?

Community
  • 1
  • 1
neworld
  • 7,629
  • 3
  • 37
  • 59

3 Answers3

6
$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.

Lightness Races in Orbit
  • 369,052
  • 73
  • 620
  • 1,021
4

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);
//-------------------------------------------^^^^^^^^
Michael Berkowski
  • 260,803
  • 45
  • 432
  • 377
-2
$null = NULL;

Conrad Frix
  • 50,756
  • 12
  • 89
  • 148
Dejan Marjanović
  • 19,004
  • 7
  • 50
  • 66