diff --git a/Backend/Home/Common/function.php b/Backend/Home/Common/function.php new file mode 100644 index 0000000..22b9859 --- /dev/null +++ b/Backend/Home/Common/function.php @@ -0,0 +1,43 @@ +'; + // 如果是boolean或者null直接显示文字;否则print + if (is_bool($data)) { + $show_data = $data ? 'true' : 'false'; + } elseif (is_null($data)) { + $show_data = 'null'; + } else { + $show_data = print_r($data, true); + } + $str .= $show_data; + $str .= ''; + echo $str; +} + +/** + * php cli模式执行php文件 + * 测试 + */ +function cli_test() +{ + $count = 0; + while(true){ + $count++; + echo $count."\r\n"; + if($count > 10){ + break; + } + sleep(3); + } + echo 'done'; +} \ No newline at end of file diff --git a/Backend/Home/Controller/DataBaseController.class.php b/Backend/Home/Controller/DataBaseController.class.php index 1cdd1fb..ff23c96 100644 --- a/Backend/Home/Controller/DataBaseController.class.php +++ b/Backend/Home/Controller/DataBaseController.class.php @@ -119,12 +119,32 @@ public function createRedis() return $rPushResul; } - public function executeFunction() + /** + * php cli模式执行php文件 + * 模拟队列发送邮件 + */ + public function executeCli() + { + $dir = 'D:\wamp\bin\php\php5.5.12>php.exe'; + exec("D:\wamp\bin\php\php5.5.12>php.exe ../cli_test.php"); + } + + /** + * php cli模式执行php文件 + * D:\wamp\bin\php\php5.5.12>php.exe ../cli_test.php + */ + public function cli_test() { - for ($x=0; $x<=10000; $x++) - { - $this->createRedis(); + $count = 0; + while(true){ + $count++; + file_put_contents("./test_result.txt",$count."\r\n",FILE_APPEND); + if($count > 10){ + break; + } + sleep(3); } + echo 'done'; } diff --git a/admin.php b/admin.php index 34745f8..c702f10 100644 --- a/admin.php +++ b/admin.php @@ -31,13 +31,10 @@ * new:http://serverName/home.php/index */ //define('BIND_CONTROLLER','Index'); +//php-cli http://www.thinkphp.cn/topic/34761.html // 定义应用目录 -define('APP_PATH','./Backend/'); +define('APP_PATH',dirname(__FILE__).'/Backend/'); // 引入ThinkPHP入口文件 -require './ThinkPHP/ThinkPHP.php'; - - - -// 亲^_^ 后面不需要任何代码了 就是如此简单 +require dirname( __FILE__).'/ThinkPHP/ThinkPHP.php'; diff --git a/admin_bak.php b/admin_bak.php new file mode 100644 index 0000000..f2c71f9 --- /dev/null +++ b/admin_bak.php @@ -0,0 +1,47 @@ + + + + +// +---------------------------------------------------------------------- + +// 应用入口文件 + +// 检测PHP环境 +if(version_compare(PHP_VERSION,'5.3.0','<')) die('require PHP > 5.3.0 !'); + +// 开启调试模式 建议开发阶段开启 部署阶段注释或者设为false +define('APP_DEBUG',True); + +/** + * 绑定Home模块到当前入口文件(3.2.1以上版本写法) + * old:http://serverName/index.php/Home/Index/index + * new:http://serverName/home.php/Index/index + */ +//define('BIND_MODULE','Home'); + + +/** + * 绑定Index控制器到当前入口文件(3.2.1以上版本写法) + * old:http://serverName/index.php/Home/Index/index + * new:http://serverName/home.php/index + */ +//define('BIND_CONTROLLER','Index'); + +// 定义应用目录 +define('APP_PATH','./Backend/'); + +// 引入ThinkPHP入口文件 +require './ThinkPHP/ThinkPHP.php'; + + + +// 亲^_^ 后面不需要任何代码了 就是如此简单 +