Catchable fatal error: Object of class HelloWorldClass could not be converted to string in /Applications/XAMPP/xamppfiles/htdocs/wisd_activity04c.php on line 19
This program is supposed to output 1. "Hello World!" in red/40px font 2. "Hello World!" in green/20px font and underlined
<?php
echo '60-334 ACTIVITY 4 PART 3/3<br><br>';
class HelloWorldClass
{
public $font_size;
public $font_colour;
public $hello_string;
function __construct($size, $colour)
{
$this->font_size = $size;
$this->font_colour = $colour;
$this->hello_string = "Hello World!";
}
public function custom_show()
{
echo "<font color=\"$this.font_colour\" size=\"$this.font_size\">$this.hello_string</font>";
}
}
class Sub_HelloWorldClass extends HelloWorldClass
{
function __construct($size, $colour)
{
parent::__contruct($font, $colour);
}
public function custom_show()
{
echo "<u><font color=\"$this.font_colour\" size=\"$this.font_size\">$this.hello_string</font></u>";
}
}
$object = new HelloWorldClass('40px', 'red');
$object->custom_show();
$object = new Sub_HelloWorldClass('20px', 'green');
$object->custom_show();
?>