test - 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 test.php

  1. <?php
  2.  
  3.  
  4. class Customer {
  5.     private $name;
  6.     
  7.     public function __construct(string $name = null) {
  8.         $this->name = $name;
  9.     }
  10.     
  11.     public function getName(): ?string {
  12.         return $this->name;
  13.     }
  14. }
  15.  
  16. $customer = new Customer();
  17.  
  18. $foo = $customer->getName() ?: 'hola';
  19.  
  20. var_dump($foo);
File Description
  • test
  • PHP Code
  • 23 Jan-2020
  • 306 Bytes
You can Share it: