我在网站上有一个脚本,我们称之为my_script.php。 在同一台服务器中,我有一个 cakephp 2.3 应用程序,它具有运行某些后台任务的特定控制器/操作。该功能可以通过http://example.com/controller/action/param1
等URL调用现在我需要这样做,所以每次加载my_script.php
时,它都会调用我在上面提到的发送参数的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¶m1=param1');
但这些似乎都不起作用。是否可以或者我应该使用完整的URL?或者可能没有使用file_get_contents()
而是使用其他东西?