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

  1. <?php
  2.  
  3. $strTemplate = "My name is :name, not :name2.";
  4. $strParams = [
  5.   ':name' => 'Dave',
  6.   'Dave' => ':name2 or :password', // a wrench in the otherwise sensible input
  7.   ':name2' => 'Steve',
  8.   ':pass' => '7hf2348', // sensitive data that maybe shouldn't be here
  9. ];
  10.  
  11. echo strtr($strTemplate, $strParams);
  12. // "My name is Dave, not Steve."
  13.  
  14. echo str_replace(array_keys($strParams), array_values($strParams), $strTemplate);
  15. // "My name is Steve or 7hf2348word, not Steve or 7hf2348word2."
  16.  
  17. ?>
File Description
  • myfile.php
  • PHP Code
  • 27 Mar-2021
  • 506 Bytes
You can Share it: