3v4l.org

run code in 300+ PHP versions simultaneously
<?php $functionName = 'MyFunction'; // Create function with the name defined in variable $functionName function $functionName($argument) { return 'Argument passed is: '.$argument; } var_dump(MyFunction('Calling MyFunction directly.')); var_dump({'MyFunction'}('Calling MyFunction with string.'));
Output for 5.4.0 - 5.4.17
Parse error: syntax error, unexpected '$functionName' (T_VARIABLE), expecting identifier (T_STRING) or '(' in /in/Yhfq8 on line 5
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING or '(' in /in/Yhfq8 on line 5
Process exited with code 255.

preferences:
181.96 ms | 1395 KiB | 53 Q