1

I am geting:

"Notice: Undefined variable: single_ad_data in"...

"Notice: Undefined variable: full_ad_data in"...

class Example {
public $page;
public $test_array, $single_ad_data, $get_full_ad_data=array(); 

public function __construct (array $test_array) {
    $this->test_array = $test_array;
    $this->single_ad_data = $single_ad_data;
    $this->full_ad_data = $full_ad_data;
    $this->page = $page=new DOMDocument;
   }
}
t-str-os
  • 57
  • 6
  • 5
    Possible duplicate of [PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset"](http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-notice-undefined-index-and-notice-undef) – hassan May 21 '17 at 07:46
  • 1
    the error is explanatory , you need to define `$single_ad_data` and `$full_ad_data` – hassan May 21 '17 at 07:46
  • I don't understand - aren't they defined in 3rd line as an empty array? – t-str-os May 21 '17 at 07:50
  • na na, you've defined an object properties, for example `$this->full_ad_data` this is a valid php variable, but the `$full_ad_data` is considered as a out-of-scope variable, you need to pass it - as $test_array` or define it – hassan May 21 '17 at 07:51

1 Answers1

0

You need to assign your variables values. Looks like you wanted to set them when instantiating a new class: pass them as parameters into the constructor, just like you did with your test_array.

Astranormal
  • 106
  • 5