米
心情
所有
图集
登录
搜索
原创
php命令行获取用户输入接收用户输入
米醋儿
发布于:2021-11-05
``` #!/usr/bin/env php <?php //教程1 https://micuu.com/new/2305.html //cmd /c D:\phpstudy_pro\Extensions\php\php7.3.4nts\php.exe C:\Users\Administrator\Desktop\index.php "%1" // echo '您输入的信息是:'.$name."\r\n"; // composer require intervention/image //下载完成后运行命令 // http://image.intervention.io/use/basics //官方文档地址 require __DIR__.'/vendor/autoload.php'; use Intervention\Image\ImageManagerStatic as Image; //需要用户输入的字段 $needInput = [ 'width' => "", 'hei' => "", 'logo' => "", ]; //字段提示 注意:其中 key 需要和 needinput数组中的 key 对应 $outMsg = [ 'width' => "宽度", 'hei' => "高度", 'logo' => "水印", ]; $fs = true; //用户输入状态 当用户灭有输入的时候是true,输入后是false foreach($needInput as $k => $v){ do{ if($fs){ fwrite(STDOUT,$outMsg[$k]); $fs = false; }else{ fwrite(STDOUT,"抱歉,{$outMsg[$k]} 不能为空,请重新输入{$outMsg[$k]}:"); } $needInput[$k] = trim(fgets(STDIN)); if($needInput[$k] != ''){ $fs = true; } }while($needInput[$k] == ''); } print_r($needInput); // and you are ready to go ... $img = Image::make("C:/Users/Administrator/Pictures/3.png")->resize(300, 200); // save file as jpg with medium quality $res = $img->save("C:/Users/Administrator/Pictures/3.png副本.jpg", 60); if($res == true){ echo "图片处理成功"; }else{ echo "图片处理失败"; } // // create new Intervention Image // $img = Image::make('public/foo.jpg'); // // paste another image // $img->insert('public/bar.png'); // // create a new Image instance for inserting // $watermark = Image::make('public/watermark.png'); // $img->insert($watermark, 'center'); // // insert watermark at bottom-right corner with 10px offset // $img->insert('public/watermark.png', 'bottom-right', 10, 10); ```
注:原创不易,转载请注明出处(
http://micuu.com/new/2346.html
),本站所有资源来源于网络收集,如有侵权请联系QQ245557979进行清除。
最后修改与 2022-02-18
上一篇:
火狐浏览器点击任何地方都会出现光标
下一篇:
完整代码:鼠标右键实现命令行裁剪图片及添加水印代码
留言反馈
请先登录
问题反馈渠道,如有软件无法下载或者其他问题可反馈。【由于某种原因,目前留言不展示】
用户需要登录后才能留言反馈
立即留言
珍藏视频
10分钟高效燃脂
30天高效瘦脸操
5分钟缓解颈椎操
友人
微博
全民K歌
唱吧
今日头条
悠悠网
科技小锅盖
彼岸桌面
阮一峰
laravel社区
V2ex
掘金
更多>