如何使用方法/函数从 url 调用 php 文件


How to call php file from url by using method/function?

通常我们通过从url调用file_name.php来执行php文件,而不是从url调用file_name我可以从url调用方法/函数来执行php文件吗?如果是,请举例解释我。

这是可能的,为此您需要使用反射来搜索方法。您也可以直接执行方法:

$class::$method($params);
MyClass::$method();
$this->$method();
// etc...

但我强烈建议也使用 MVC 框架。