當前位置:才華齋>設計>網頁設計>

php命令列使用方法和命令列引數有哪些

網頁設計 閱讀(2.37W)

複製程式碼 程式碼如下:

php命令列使用方法和命令列引數有哪些

[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 /]#