demo - 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.



Your result can be seen below.

Result of php executing





Full code of demo.php

  1. <?php
  2. class Dog {
  3.         var $breed;
  4.         var $size;
  5.         var $intelligence;
  6.        
  7.         function set_breed($new_breed){
  8.                 $this->breed= $new_breed;
  9.         }
  10.         function get_breed() {
  11.                 return $this->breed;
  12.         }
  13.        
  14.         function set_size($new_size){
  15.                 $this->size= $new_size;
  16.         }
  17.        
  18.         function get_size() {
  19.                 return $this->size;
  20.         }
  21.        
  22.         function set_intelligence($new_intelligence){
  23.                 $this->intelligence= $new_intelligence;
  24.         }
  25.        
  26.         function get_intelligence() {
  27.                 return $this->intelligence;
  28.         }
  29. }
  30.        
  31. $Husky = new dog();
  32.  
  33. $Husky->set_breed("Husky");
  34. $Husky->set_size("Medium");
  35. $Husky->set_intelligence("5");
  36.  
  37.  
  38. echo $Husky->set_breed("Husky"). "</br>";
  39. echo $Husky->set_size("Medium"). "</br>";
  40. echo $Husky->set_intelligence("5") ."</br>";
File Description
  • demo
  • PHP Code
  • 04 Feb-2021
  • 693 Bytes
You can Share it: