Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-Type: application/json');
- $aResult = array();
- if( !isset($_POST['functionname']) ) { $aResult['error'] = 'No function name!'; }
- if( !isset($_POST['arguments']) ) { $aResult['error'] = 'No function arguments!'; }
- if( !isset($aResult['error']) ) {
- switch($_POST['functionname']) {
- case 'add':
- if( !is_array($_POST['arguments']) || (count($_POST['arguments']) < 1) ) {
- $aResult['error'] = 'Error in arguments!';
- }
- else {
- $aResult['result'] = add(floatval($_POST['arguments'][0]));
- }
- break;
- default:
- $aResult['error'] = 'Not found function '.$_POST['functionname'].'!';
- break;
- }
- }
- echo json_encode($aResult);
- function add($a){
- return $a;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement