从URL调用PHP函数? [英] Call PHP function from url?

查看:296
本文介绍了从URL调用PHP函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想执行php脚本,我只需将浏览器指向www.something.com/myscript.php

If I want to execute a php script, i just point the browser to www.something.com/myscript.php

但是,如果我想在myscript.php内部执行特定功能,是否有办法?类似于www.something.com/myscript.php.specificFunction

But if i want to execute a specific function inside myscript.php, is there a way? something like www.something.com/myscript.php.specificFunction

谢谢!

推荐答案

一种快速方法是做类似的事情

something.com/myscript.php?f=your_function_name

然后在myscript.php中

then in myscript.php

if(function_exists($_GET['f'])) {
   $_GET['f']();
}

但是请为了所有小猫的爱,不要滥用它.

But please, for the love of all kittens, don't abuse this.

这篇关于从URL调用PHP函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆