包含和调用来自 cakePHP 的外部 php 脚本


Including and calling external php scripts from cakePHP

在服务器上,我有php脚本负责向手机发送通知。如果从同一目录调用脚本,则运行良好。

问题是从 cakePHP 应用程序调用脚本。

我将通知脚本包含在 cakePHP 函数中,如下所示:

include $_SERVER['DOCUMENT_ROOT'].'/folder_name/Notifications.php';

调用脚本时,脚本内收到以下警告:

include_once(./db_connect.php) [function.include-once]: failed to open stream: No such file or directory [/home/username/public_html/gcm_server_php/db_functions.php
Warning (2): include_once() [function.include]: Failed opening './db_connect.php' for inclusion (include_path='/home/username/public_html/cake-dev/lib:.:/usr/lib/php:/usr/local/lib/php') [/home/username/public_html/gcm_server_php/db_functions.php, line 21]

以及以下致命错误:

Error: Class 'DB_Connect' not found 
File: /home/username/public_html/gcm_server_php/db_functions.php    
Line: 25

任何帮助都非常感谢。请记住,从同一目录调用脚本,一切都运行顺利。

整个应用程序中的所有包含链接都是错误的。需要做的是包含其他文件和绝对路径,如下所示:

包括 $_SERVER["DOCUMENT_ROOT"]。/folder_name/通知.php';