PHP和Nodejs能配合使用吗
1个回答
展开全部
这样试试吧* 返回的汉语文字信息在windows中是GB2312编码,需要手动改成UTF8
* iconv("GB2312","UTF-8",$read);
* @param $cmd
* @return array
*/
public function execFront($cmd)
{
$response = array();
$handle = popen("$cmd 2>&1", 'r');
while ($read = fread($handle, 20096)) {
if(!mb_detect_encoding($read, 'UTF-8', true))
iconv("GB2312"闷册,"UTF-8",$read);
$response[] = trim($read);
}
pclose($handle);
flush();
return $response;
}
/**
* @param $cmd
*/
public function execBackend($cmd)
{
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start cmd /c ". $cmd, "r"));
}
else {
exec($cmd . "手闹 > /dev/null &");
}
return;
},还有不懂的可以问我,我在毕罩罩后盾网学习呢马上就上课了,(ಡωಡ)hiahiahia 加油加油
* iconv("GB2312","UTF-8",$read);
* @param $cmd
* @return array
*/
public function execFront($cmd)
{
$response = array();
$handle = popen("$cmd 2>&1", 'r');
while ($read = fread($handle, 20096)) {
if(!mb_detect_encoding($read, 'UTF-8', true))
iconv("GB2312"闷册,"UTF-8",$read);
$response[] = trim($read);
}
pclose($handle);
flush();
return $response;
}
/**
* @param $cmd
*/
public function execBackend($cmd)
{
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start cmd /c ". $cmd, "r"));
}
else {
exec($cmd . "手闹 > /dev/null &");
}
return;
},还有不懂的可以问我,我在毕罩罩后盾网学习呢马上就上课了,(ಡωಡ)hiahiahia 加油加油
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询