RT
小弟用函数system来返回可是这样返回的话内容会直接显示到页面里
能不能获取返回的值而不显示到页面上呀?另比如system("/usr/bin/sudo /sbin/fdisk -l /dev/sdb");
返回到页面的值是:Disk /dev/sdb: 3221 MB, 3221225472 bytes 255 heads, 63 sectors/track, 391 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 * 1 391 3140676 83 Linux Partition 1 has different physical/logical endings: phys=(1023, 254, 63) logical=(390, 254, 63) 2097152如上所属 我想取得对应的ID:83 我应该怎么取得呀 (因为当ID等于83的时候 说明分区的系统就是Linux系统)
请各位高手帮帮小弟的忙呀

解决方案 »

  1.   

    system默認返回最後一行
    例子 1. system() example<?php
    echo '<pre>';// Outputs all the result of shellcommand "ls", and returns
    // the last output line into $last_line. Stores the return value
    // of the shell command in $retval.
    $last_line = system('ls', $retval);// Printing additional info
    echo '
    </pre>
    <hr />Last line of the output: ' . $last_line . '
    <hr />Return value: ' . $retval;
    ?>  
      

  2.   

    可以参考这篇帖子
    http://topic.csdn.net/u/20071229/13/4b44b5b4-1ed9-49ca-8a00-bce0ad2896ee.html
    还有这篇帖子
    http://zhuwenlong.blog.51cto.com/209020/40021
    没有玩过, 希望对你有帮助。