我有一些名为file1.php、file2.php、file3.php的PHP文件。现在,我希望从名为all.php的其他PHP文件中逐个运行这些PHP文件。我的意思是file2.php将在file1.php完成后执行。File3.php将在file2.php完成后执行。怎么做?
我可以使用exec函数吗?我的主机安全吗?我正在使用Cpanel在共享主机。有任何方法去做,但我的内容在托管安全?
非常感谢!
发布于 2014-11-27 06:53:52
您可以使用include()
include('file1.php');
include('file2.php');
include('file3.php');或include
include_once('file1.php');
include_once('file2.php');
include_once('file3.php');或require或require
require 'file1.php';
require 'file2.php';
require 'file3.php';=> require()将产生一个致命错误(E_COMPILE_ERROR)并停止脚本
=> include()只会产生警告(E_WARNING),脚本将继续。
发布于 2014-11-27 06:32:40
在文件all.php中,您可以这样做:
include('file1.php');
include('file2.php');
include('file3.php');发布于 2014-11-27 07:03:03
是的,你可以使用'exec‘函数,也可以作为备用'system','passthru’函数。
但在这种情况下,您的文件即“file1.php”、“file2.php”和“file3.php”。
https://stackoverflow.com/questions/27164361
复制相似问题