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

  1. final class Product {
  2.  
  3.     private static $instance;
  4.     public $a;
  5.  
  6.     public static function getInstance() {
  7.         if (!(self::$instance instanceof self)) {
  8.             self::$instance = new self();
  9.         }
  10.         return self::$instance;
  11.     }
  12.  
  13.     private function __construct() {}
  14.     private function __clone() {}
  15.     private function __sleep() {}
  16.     private function __wakeup() {}
  17. }
  18.  
  19. $firstProduct  = Product::getInstance();
  20. $secondProduct = Product::getInstance();
  21.  
  22. $firstProduct->a  = 1;
  23. $secondProduct->a = 2;
File Description
  • webpractik-test-st
  • PHP Code
  • 16 Sep-2021
  • 547 Bytes
You can Share it: