I'm learning PHP and reading through a Robin Nixon book. I'm having trouble with this code:
<?php
class Centre
{
public $centre_name; // String: The name of the centre
public $tagline; // String: The centre's tagline
// Set the centres details. This will later be done through a form.
function set_details()
{
$this->centre_name = "YMCA";
$this->tagline = "Lets all go to the Y";
}
// Display the centres details.
function display()
{
echo "Centre Name - " . $centre->centre_name . "<br />";
echo "Centre Tagline - " . $centre->tagline . "<br />";
}
}
?>
<?php
$centre = new Centre();
$centre->set_details();
$centre->display();
?>
Right now this is outputing: Centre Name - Centre Tagline - So the variables are being set. Am I using $this->variable = "whatever"; correctly?