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,757
  • 3
  • 39
  • 61

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
  • 378,754
  • 76
  • 643
  • 1,055
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
  • 267,341
  • 46
  • 444
  • 390
-2
$null = NULL;

Conrad Frix
  • 51,984
  • 12
  • 96
  • 155
Dejan Marjanović
  • 19,244
  • 7
  • 52
  • 66