Last active
March 3, 2023 03:22
-
-
Save ssddanbrown/bdeac0c9409a6d2712e396a0ab6c7de1 to your computer and use it in GitHub Desktop.
console.log in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Note: The namespace is required since a 'log' function already exists in PHP | |
// and that can't be overriden without having an extension installed, so we | |
// use a namespace which allows us to use the function name. | |
namespace app; | |
const console = ''; | |
function log(...$args) { | |
var_dump(...$args); | |
return ''; | |
} | |
console.log('thingA', 5, [1,2]); | |
// Outputs: | |
// test.php:16: | |
// string(6) "thingA" | |
// test.php:16: | |
// int(5) | |
// test.php:16: | |
// array(2) { | |
// [0] => | |
// int(1) | |
// [1] => | |
// int(2) | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment