Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Beverage {
- public $temperature, $color, $opacity;
- function getInfo() {
- return "This beverage is $this->temperature and $this->color.";
- }
- //constructor to set parameters to their respective object properties
- function __construct($temperature, $color){
- $this->temperature = $temperature;
- $this->color = $color;
- }
- }
- $tea = new Beverage("cold", "black"); // enter arguments to invoke constructor in creating new object
- echo $tea->getInfo();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement