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.
Result of php executing
Full code of myfile.php.php
- <?php
- $strTemplate = "My name is :name, not :name2.";
- $strParams = [
- ':name' => 'Dave',
- 'Dave' => ':name2 or :password', // a wrench in the otherwise sensible input
- ':name2' => 'Steve',
- ':pass' => '7hf2348', // sensitive data that maybe shouldn't be here
- ];
- echo strtr($strTemplate, $strParams);
- // "My name is Dave, not Steve."
- echo str_replace(array_keys($strParams), array_values($strParams), $strTemplate);
- // "My name is Steve or 7hf2348word, not Steve or 7hf2348word2."
- ?>