/ Published in: PHP
Place your functions below the header and then call them by posting to the script with any kind of ajax : $('#test').load('base/ajax/ajaxapi.php',{method:'sha256',params:"'batman','gargamelhatessmurfs'"}); for example.
Expand |
Embed | Plain Text
/** * AJAX API FOR PHP FUNCTION LIBRARY */ if(function_exists(stripslashes(trim($_POST['method'])))){ //IF THE FUNCTION EXISTS (IN THIS SCRIPT) $function = new ReflectionFunction($method); //instantiate the function as an object $function->invokeArgs($opts); //invoke the function with an array of arguments (if given) }else{ //ELSE THE FUNCTION DOES NOT EXIST echo "error the function you called : ".$_POST['method']."(".$_POST['params'].")"." does not exist"; exit; } exit; ///////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////// // PLACE YOUR FUNCTIONS BELOW HERE. // ///////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////
You need to login to post a comment.
