HTML
CSS
PHP
Deno
Examples
Do It Yourself
Blog
Type in your code below
Run
<?php class Shape { public $width; public $height; public $color; public function __construct($width, $height, $color) { $this->width = $width; $this->height = $height; $this->color = $color; } public function description(){ return 'This shape is '.$this->width.'cm long, '.$this->height.'cm high and is '.$this->color.' in color'; } } $shape = new Shape(20,20,'green'); echo $shape->description(); //outputs: This shape is 20 long, 20 high and is green in color ?>
Related Chapters
PHP Math
PHP Operators
PHP Boolean
PHP Arrays
PHP Numbers
Related Examples
PHP Constants Example
PHP Math sqrt() Example
PHP Boolean Logical NOT Example
PHP Boolean Conversion Example
PHP Boolean Example