我正在寻找从php文件获取数据json的方法,而又不知道功能PHP文件正在处理。
<script>
function clickButton(){
var s = document.createElement("script");
s.src = "jsonp_demo_db.php?callback=myDisplayFunction";
document.body.appendChild(s);
}
</script>
带有获取请求的函数名称,并检查是否存在get value并使用call_user_func($functionName)
,如果有参数,则可以使用call_user_func_array($functionName , $pramaters)
`function test()
{
echo "string";
}
if ($_GET['func']) {
$func = $_GET['func'];
call_user_func($func);
}`
您还可以使用function_Exists inshure如果存在该函数,并且此函数返回false或true此代码示例:
if(function_exists('my_function'))
{
throw new Exception("'my_function' is already defined!");
}
function my_function()
{
// Do the work here
}