Reputation: 198
This code doesn't work. The $_GET variables are set, but this code always returns $model, $manufacturer, etc, as being empty. What am I doing wrong?
<?php
class Tiles extends Phones {
private $model;
private $manufacturer;
private $all;
function __construct() {
$this->model = $_GET['model'] ?? null;
$this->manufacturer = $_GET['manufacturer'] ?? null;
$this->all = $_GET;
}
function showEntry() {
echo $model;
}
}
?>
This is my first time using the __construct
method, so if i'm missing something obvious, please, point me in the right direction.
Edit: I should add, if I simply use $_GET['model'], etc in my showEntry() method, it works.
Upvotes: 0
Views: 867
Reputation: 168
You should echo $this->model;
instead of just echo $model;
inside of showEntry()
.
Upvotes: 3