大家知道php可以通过exec、system等函数执行第三方程序,但是第三方程序有用户输入这一块,使用exec或system执行的话直接忽略,请问php如何执行第三方程序并等待用户输入?
网友回复
如何是使用php cli来执行获取用户输入的命令
<?php echo "Are you sure you want to do this? Type 'yes' to continue: "; $handle = fopen ("php://stdin","r"); $line = fgets($handle); if(trim($line) != 'yes'){ echo "ABORTING!\n"; exit; } echo "\n"; echo "Thank you, continuing...\n"; ?>如果执行第三方程序的话
<?php // file: proc.php // proc_open parameters $descriptorspec = array( 0 => array("pipe", "r"), // stdin is a pipe that the child will read from 1 => array("pipe", "w"), // stdout is a pipe that the child will writ...
点击查看剩余70%
<?php $descriptorspec = array( 0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "r") ); $process = proc_open('php test_gen.php', $descriptorspec, $pipes, null, null); //run test_gen.php echo ("Start process:\n"); if (is_resource($process)) { fwrite($pipes[0], "start\n"); // send start echo ("\n\nStart ....".fgets($pipes[1],4096)); //get answer fwrite($pipes[0], "get\n"); // send get echo ("Get: ".fgets($pipes[1],4096)); //get answer fwrite($pipes[0], "stop\n"); //send stop echo ("\n\nStop ....".fgets($pipes[1],4096)); //get answer fclose($pipes[0]); fclose($pipes[1]); fclose($pipes[2]); ...
点击查看剩余70%
腾讯混元模型广场里都是混元模型的垂直小模型,如何api调用?
为啥所有的照片分辨率提升工具都会修改照片上的图案细节?
js如何在浏览器中将webm视频的声音分离为单独音频?
微信小程序如何播放第三方域名url的mp4视频?
ai多模态大模型能实时识别视频中的手语为文字吗?
如何远程调试别人的chrome浏览器获取调试信息?
为啥js打开新网页window.open设置窗口宽高无效?
浏览器中js的navigator.mediaDevices.getDisplayMedia屏幕录像无法录制SpeechSynthesisUtterance产生的说话声音?
js中mediaRecorder如何录制window.speechSynthesis声音音频并下载?
python如何直接获取抖音短视频的音频文件url?