複製代碼 代碼如下:
[root@localhost /]#
[root@localhost /]# PHP -r "var_dump(true);" # 執行PHP代碼 不需要 標籤
bool(true)
[root@localhost /]# php -R "var_dump(true);" # 執行PHP代碼 每一個輸入行
bool(true)
bool(true)
bool(true)
[root@localhost /]#
[root@localhost /]# php -f "file" # 執行php代碼 來自檔案
[root@localhost /]#
[root@localhost /]# php "" id name sex
int(4)
Array
(
[0] =>
[1] => id
[2] => name
[3] => sex
)
[root@localhost /]#
[root@localhost /]# cat
<?php
var_dump($_SERVER["argc"]); // 獲取命令行傳入參數的`數量
print_r($_SERVER["argv"]); // 獲取命令行傳入參數的數組
[root@localhost /]#