Last active
December 28, 2015 22:59
-
-
Save jocoonopa/7575993 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo "system<br/>"; | |
echo "<pre>會將內容直接輸出:</pre>"; | |
echo "<pre>"; | |
$last_line = system('ls', $status_code); | |
echo "</pre>"; | |
echo "<pre>只會有最後一行:".$last_line."</pre>"; | |
echo "<pre>狀態碼:".$status_code."</pre>"; | |
echo "<hr/>passthru:<br/><pre>"; | |
passthru ('echo $PATH'); | |
echo "</pre><br/>"; | |
echo "<hr/>exec<br/>"; | |
exec( 'ls', $output, $status_code); | |
echo "<pre>儲存成陣列:</pre>"; | |
echo "<pre>"; | |
print_r( $output ); | |
echo "</pre>"; | |
echo "<pre>狀態碼:".$status_code."</pre>"; | |
echo "<hr/>shell_exec:<br/>"; | |
$output = shell_exec( 'ls' ); | |
echo "<pre>儲存成文字:</pre>"; | |
echo "<pre>"; | |
print_r( $output ); | |
echo "</pre>"; | |
echo "<hr/>popen:<br/>"; | |
echo "<pre>類似於fopen</pre>"; | |
$pipe = popen("/bin/ls", 'r'); | |
while ($s = fgets($pipe, 1024) ){ | |
$arr[] = $s; | |
} | |
pclose( $pipe ); | |
echo "<pre>"; | |
print_r ($arr); | |
echo "</pre>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment