php命令行界面
php  /  管理员 发布于 3年前   168
常用选项php -vphp -i PHP安装的有关信息php -h 访问帮助文件php -m 列出编译到当前PHP安装的所有模块执行一段代码php -r 'echo "hello, world!";'php -r 'echo "Hello, World!\n";'php -r '$ts = filemtime("/data/www/index.html");> echo date("F j Y H:clear:s", $ts);'php -r 'echo "Hello, world! \n\n";'交互php -aecho 'hello world';$arr = ['who', 'what', 'when'];echo $arr[1];创建命令行脚本vim dummy.php```#!/usr/bin/php<?php// do whatever.?>This text is also displayed.<?php?>```php dummy.phpvim number.php```#!/usr/bin/php<?php$file = 'readme.txt';echo "\nNumbering the file named '$file' ----------------\n\n";$data = file($file);$n = 1;foreach($data as $line) {echo "$n $line";$n++;}echo "\n $file 文件结束\n";```运行的方式php number.phpphp -f number.phpchmod +x number.php./number.php检查语法, 但是不能检查严重错误php -l number.php使用命令行参数vim number2.php```#!/usr/bin/php<?phpif($_SERVER['argc'] == 2) {$file = $_SERVER['argv'][1];if(file_exists($file) && is_file($file)) {echo "\nNumbering the file named '$file' ----------------\n\n";if( $data = file($file) ){$n = 1;foreach($data as $line) {echo "$n $line";$n++;}echo "\n $file 文件结束\n";exit(0);} else {echo "文件不能读取\n";}} else {echo "文件不存在.\n";exit(1);}} else {echo "\nUsage: number2.php <filename>\n\n";exit(1);}```php number2.php filename接受输入vim init.php```#!/usr/bin/php<?phpecho "\n请输入安装的一个模式?\n\n[0]开发模式\n[1]线上模式\n你选择[0-1, 或者\"q\"退出]";if(fscanf(STDIN, '%d', $mode)==1) { //如果返回的结果不是1, 也就是没有读取一个数字, 脚本会执行elseif($mode==0) {echo "\n你选择了开发模式, 进行开发模式配置\n";} else {echo "\n你选择了开发模式, 进行开发模式配置\n";}} else { echo "\n请输入一个数字进行选择\n";}```内置服务器php -h 如果有大S和-t选项表示支持内置服务器 -t 指定网站根目录php -S localhost:8080php -S localhost:8080 -t /data/www然后可以在浏览器中访问, 或者通过curl访问
路人 在
php中使用hyperf框架调用讯飞星火大模型实现国内版chatgpt功能示例中评论 教程很详细,如果加个前端chatgpt对话页面就完美了..博主 在
科学上网翻墙之v2rayN-Core客户端免费公益节点使用教程中评论 @ mashrdn 多切换几个节点测试,免费ssr是没那么稳..mashrdn 在
科学上网翻墙之v2rayN-Core客户端免费公益节点使用教程中评论 V2rayn免费节点添加上去了,youtobe无法打开网页,是怎么回事..张伟 在
科学上网翻墙之v2rayN-Core客户端免费公益节点使用教程中评论 3q!有用,不过免费节点隔天就要去git上复制新的导进去..博主 在
科学上网翻墙访问Google , 上外网神器佛跳墙VPN(永久免费)使用流程步骤中评论 该篇教程已不能用了,告知大家,免的老有老铁问我!..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号