我在网站上有一个脚本,我们称之为my_script.php . 在同一台服务器中,我有一个 cakephp 2.3 应用程序,它具有运行某些后台任务的特定控制器/操作 . 该函数可以通过URL调用,如http://example.com/controller/action/param1

现在我需要在每次加载_1182672时都这样做,它会调用我在上面提到的发送参数的cakephp函数 .

我可以轻松地使用它

$result = file_get_contents('http://example.com/controller/action/param1');

但是,由于两个脚本都位于同一个服务器中,因此在我看来,不必进行DNS请求,甚至只需使用服务器的IP来调用cakephp函数 .

有没有办法在不使用公共URL(并传递参数)的情况下进行调用?我的意思是使用文件路径 . 我试过了:

$result = file_get_contents('/controller/action/param1');

$result = file_get_contents('/path/to/app/webroot/index.php/controller/action/param1');

$result = file_get_contents('/path/to/app/webroot/index.php?controller=controller&action=action&param1=param1');

但这些似乎都没有奏效 . 是否可以或者我应该使用完整的URL?或者也许不使用 file_get_contents() 而是其他什么?