8. - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of 8..php
- <?php
- class car
- {
- public $thing;
- public function __construct($thing) {
- $this->thing = $thing;
- }
- public function message() {
- return "My car is " . $this->thing;
- }
- }
- class model
- {
- public $model;
- public function __construct($other) {
- $this->other = $other;
- }
- public function message() {
- return "My car is a " . $this->other;
- }
- }
- class complaint
- {
- public $model;
- public function __construct($complaint,$why) {
- $this->complaint = $complaint;
- $this->why = $why;
- }
- public function message() {
- return "I wish it was a " . $this->complaint. " ".$this->why;
- }
- }
- $myCar = new Car("grey");
- echo $myCar -> message();
- echo "<br>";
- $myCar = new model("SUV");
- echo $myCar -> message();
- echo "<br>";
- $myCar = new model("Ford");
- echo $myCar -> message();
- echo "<br>";
- $myCar = new complaint("red", "Toyota");
- echo $myCar -> message();
- ?>
File Description
- 8.
- PHP Code
- 24 Feb-2021
- 880 Bytes
You can Share it:
Latest PHP Pastes