Apparently you people are having a problem with my shortcut. So here is the complete 2 files.
This is the lab.php file:<?php declare(strict_types=1);
require_once("dog.php");
$lab = new Dog;
bool $dog_error_message = $lab->set_dog_name('Fred');
print $dog_error_message ? 'Name update successful<br/>' : 'Name update not successful<br/>';
bool $dog_error_message = $lab->set_dog_weight(50);
print $dog_error_message ? 'Weight update successful<br/>': 'Weight update not successful<br/>';
bool $dog_error_message = $lab->set_dog_breed('Lab');
print $dog_error_message ? 'Breed update successful<br/>' : 'Breed update unsuccessful<br/>';
bool $dog_error_message = $lab->set_dog_color('Yellow');
print $dog_error_message ? 'Color update successful<br/>' : 'Color update not successful<br/>';
//Get properties
$dog_properties = $lab->get_pr0perties();
list($dog_weight, $dog_breed, $dog_color) = explode(',', $dog_properties);
print "Dog weight is $dog_weight. Dog breed is $dog_breed. Dog color is $dog_color $dog_color.";
?>
this is the file with the class called dog.php:
<?php declare(strict_types=1);
class Dog
{
private int $dog_weight = 0;
private string $dog_breed = "no breed";
private string $dog_color = "no color";
private string $dog_name = "no name";
function get_properties() : string
{
return "$this->dog_weight, $this->dog_breed, $this->dog_color";
}
}
?>