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

  1. <?php
  2. interface Log
  3.  
  4. class LogToFile
  5. {
  6.     public function log($message)
  7.     {
  8.         echo "Please, log in a file, " $message;
  9.     }
  10. }
  11.  
  12. class LogToDB
  13. {
  14.         public function log($message)
  15.     {
  16.         echo "Please, log in a DB, " $message;
  17.     }
  18. }
  19.  
  20. class UserController
  21. {
  22.     protected logger;
  23.     
  24.     public function __construct(LogToFile $logger)
  25.     {
  26.         $this->logger=$logger;
  27.     }
  28.     public function show()
  29.     {
  30.         $user = "Seva";
  31.         $this -> logger -> log($user);
  32.     }
  33. }
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
File Description
  • 123
  • PHP Code
  • 17 Oct-2021
  • 522 Bytes
You can Share it: