Created
April 25, 2012 13:12
-
-
Save lucasmezencio/2489606 to your computer and use it in GitHub Desktop.
Command Interpreter Example
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 | |
require_once __DIR__.'/functions.php'; | |
$commands = array( | |
'hello' => array( | |
'params' => array('name') | |
), | |
'dump' => array( | |
'params' => array('var') | |
) | |
); | |
if (isset($_POST['command']) && $_POST['command'] != '') { | |
if (in_array($_POST['command'])) { | |
call_user_func($_POST['command'], $_POST['param']); | |
} | |
} |
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 | |
/** | |
* @author Lucas Mezêncio <[email protected]> | |
* | |
* @param string $name | |
*/ | |
function hello($name) { | |
echo 'Hello, '.$name; | |
} | |
/** | |
* @author Lucas Mezêncio <[email protected]> | |
* | |
* @param mixed $name | |
*/ | |
function dump($var) { | |
var_dump($var); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment