PHP停止输出系统()

I have a system() query that output's ping info, how would I stop it from doing that?

system('ping -c1 -w1 '.$addr, $return);

http://us3.php.net/exec

  • system(): Execute an external program and display the output
  • exec(): Execute an external program
  • shell_exec(): Execute command via shell and return the complete output as a string

use exec(), it doesn't output the result from the call. Or if you want the output in a string, shell_exec().

How about trying the backtick operator? http://www.php.net/manual/en/language.operators.execution.php

<?php
$output = `ls -al`;
echo "<pre>$output</pre>";
?>

This will output it into a string for you to do with as you see fit.