久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      1. <legend id='xzqpi'><style id='xzqpi'><dir id='xzqpi'><q id='xzqpi'></q></dir></style></legend>
      2. <small id='xzqpi'></small><noframes id='xzqpi'>

        • <bdo id='xzqpi'></bdo><ul id='xzqpi'></ul>
      3. <i id='xzqpi'><tr id='xzqpi'><dt id='xzqpi'><q id='xzqpi'><span id='xzqpi'><b id='xzqpi'><form id='xzqpi'><ins id='xzqpi'></ins><ul id='xzqpi'></ul><sub id='xzqpi'></sub></form><legend id='xzqpi'></legend><bdo id='xzqpi'><pre id='xzqpi'><center id='xzqpi'></center></pre></bdo></b><th id='xzqpi'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xzqpi'><tfoot id='xzqpi'></tfoot><dl id='xzqpi'><fieldset id='xzqpi'></fieldset></dl></div>

        <tfoot id='xzqpi'></tfoot>

        如何從命令行執行 PHP 代碼?

        How can I execute PHP code from the command line?(如何從命令行執行 PHP 代碼?)

          • <legend id='19UKf'><style id='19UKf'><dir id='19UKf'><q id='19UKf'></q></dir></style></legend>
                <tbody id='19UKf'></tbody>
              <tfoot id='19UKf'></tfoot>

              • <bdo id='19UKf'></bdo><ul id='19UKf'></ul>

                <small id='19UKf'></small><noframes id='19UKf'>

              • <i id='19UKf'><tr id='19UKf'><dt id='19UKf'><q id='19UKf'><span id='19UKf'><b id='19UKf'><form id='19UKf'><ins id='19UKf'></ins><ul id='19UKf'></ul><sub id='19UKf'></sub></form><legend id='19UKf'></legend><bdo id='19UKf'><pre id='19UKf'><center id='19UKf'></center></pre></bdo></b><th id='19UKf'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='19UKf'><tfoot id='19UKf'></tfoot><dl id='19UKf'><fieldset id='19UKf'></fieldset></dl></div>
                  本文介紹了如何從命令行執行 PHP 代碼?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想直接使用命令行執行一個像 if(function_exists("my_func")) echo 'function exists'; 這樣的 PHP 語句,而不必使用單獨的 PHP 文件.

                  怎么可能?

                  解決方案

                  如果您打算在命令行中執行 PHP,我建議您安裝 phpsh,一個不錯的 PHP shell.它更有趣.

                  無論如何,php 命令提供了兩個從命令行執行代碼的開關:

                  -r 運行 PHP <代碼>不使用腳本標簽 <?..?>-R<代碼>運行 PHP <代碼>對于每條輸入線

                  您可以像這樣使用 php-r 開關:

                  php -r 'echo function_exists("foo") ?是":不";'

                  上面的 PHP 命令應該 output noreturns 0 如您所見:

                  <預><代碼>>>>php -r 'echo function_exists("foo") ?是":不";'不>>>回聲 $?# 打印上一條命令的返回值0

                  另一個有趣的開關是php -a:

                  -a 作為交互式 shell 運行

                  與phpsh相比,它有點蹩腳,但如果你不這樣做想要安裝 由 Facebook 制作的很棒的 PHP 交互式 shell 以獲取選項卡完成、歷史記錄等,然后像這樣使用-a:

                  <預><代碼>>>>php -a交互式外殼php >echo function_exists(foo") ?是":不";不php >

                  如果它在你的盒子上不起作用就像在我的盒子上一樣es(在 Ubuntu 和 Arch Linux),那么可能是您的 PHP 設置模糊或損壞.如果你運行這個命令:

                  php -i |grep'API'

                  應該看到:

                  服務器 API =>命令行界面

                  如果您不這樣做,這意味著也許另一個命令將提供 CLI SAPI.試試 php-cli;也許它是您操作系統中可用的包或命令.

                  如果您看到您的 php 命令使用 CLI(命令行界面)SAPI(服務器 API),然后運行 ??php -h |grep 代碼 找出哪個瘋狂的開關 - 因為這已經一年沒有改變了 - 允許在您的版本/設置中運行代碼.

                  另外幾個例子,只是為了確保它適用于我的盒子:

                  <預><代碼>>>>php -r 'echo function_exists("sg_load") ?是":不";'不>>>php -r 'echo function_exists("print_r") ?是":不";'是的

                  另外,請注意擴展程序可能加載到 CLI 而不是 CGI 或 Apache SAPI.很可能幾個 PHP SAPI 使用不同的 php.ini 文件,例如 /etc/php/cli/php.ini/etc/php/cgi/php.ini/etc/php/apache/php.ini 在 Gentoo Linux 框.找出哪個 ini 文件與 php -i | 一起使用grep ini.

                  I would like to execute a single PHP statement like if(function_exists("my_func")) echo 'function exists'; directly with the command line without having to use a separate PHP file.

                  How is it possible?

                  解決方案

                  If you're going to do PHP in the command line, I recommend you install phpsh, a decent PHP shell. It's a lot more fun.

                  Anyway, the php command offers two switches to execute code from the command line:

                  -r <code>        Run PHP <code> without using script tags <?..?>
                  -R <code>        Run PHP <code> for every input line
                  

                  You can use php's -r switch as such:

                  php -r 'echo function_exists("foo") ? "yes" : "no";'
                  

                  The above PHP command above should output no and returns 0 as you can see:

                  >>> php -r 'echo function_exists("foo") ? "yes" : "no";'
                  no
                  >>> echo $? # print the return value of the previous command
                  0
                  

                  Another funny switch is php -a:

                  -a               Run as interactive shell
                  

                  It's sort of lame compared to phpsh, but if you don't want to install the awesome interactive shell for PHP made by Facebook to get tab completion, history, and so on, then use -a as such:

                  >>> php -a
                  Interactive shell
                  
                  php > echo function_exists("foo") ? "yes" : "no";
                  no
                  php >
                  

                  If it doesn't work on your box like on my boxes (tested on Ubuntu and Arch Linux), then probably your PHP setup is fuzzy or broken. If you run this command:

                  php -i | grep 'API'
                  

                  You should see:

                  Server API => Command Line Interface
                  

                  If you don't, this means that maybe another command will provides the CLI SAPI. Try php-cli; maybe it's a package or a command available in your OS.

                  If you do see that your php command uses the CLI (command-line interface) SAPI (Server API), then run php -h | grep code to find out which crazy switch - as this hasn't changed for year- allows to run code in your version/setup.

                  Another couple of examples, just to make sure it works on my boxes:

                  >>> php -r 'echo function_exists("sg_load") ? "yes" : "no";'
                  no
                  >>> php -r 'echo function_exists("print_r") ? "yes" : "no";'
                  yes
                  

                  Also, note that it is possible that an extension is loaded in the CLI and not in the CGI or Apache SAPI. It is likely that several PHP SAPIs use different php.ini files, e.g., /etc/php/cli/php.ini vs. /etc/php/cgi/php.ini vs. /etc/php/apache/php.ini on a Gentoo Linux box. Find out which ini file is used with php -i | grep ini.

                  這篇關于如何從命令行執行 PHP 代碼?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                • <legend id='9SWcW'><style id='9SWcW'><dir id='9SWcW'><q id='9SWcW'></q></dir></style></legend>

                    • <small id='9SWcW'></small><noframes id='9SWcW'>

                          <tbody id='9SWcW'></tbody>
                        <i id='9SWcW'><tr id='9SWcW'><dt id='9SWcW'><q id='9SWcW'><span id='9SWcW'><b id='9SWcW'><form id='9SWcW'><ins id='9SWcW'></ins><ul id='9SWcW'></ul><sub id='9SWcW'></sub></form><legend id='9SWcW'></legend><bdo id='9SWcW'><pre id='9SWcW'><center id='9SWcW'></center></pre></bdo></b><th id='9SWcW'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='9SWcW'><tfoot id='9SWcW'></tfoot><dl id='9SWcW'><fieldset id='9SWcW'></fieldset></dl></div>
                        • <bdo id='9SWcW'></bdo><ul id='9SWcW'></ul>
                          1. <tfoot id='9SWcW'></tfoot>

                            主站蜘蛛池模板: 女同久久另类99精品国产 | 一色桃子av一区二区 | 亚洲午夜精品 | 国产精品久久久一区二区三区 | 第一福利社区1024 | 国产视频第一页 | 日韩午夜影院 | 在线观看亚洲专区 | 黄色网址免费看 | 男女羞羞视频在线看 | 国产在线精品一区二区 | 99精品视频免费观看 | 色视频欧美 | 黄色毛片免费看 | 亚洲在线一区 | 久久综合一区 | 国产精品久久久久久久久久免费看 | 国产高清一区二区三区 | 亚洲电影一区二区三区 | 久久成人一区二区三区 | 九九一级片 | 久久99精品久久久久久国产越南 | 午夜在线影院 | 午夜羞羞| 国产精品美女久久久久久免费 | 亚洲国产精品久久 | 久久久精品影院 | 免费观看成人性生生活片 | 欧洲一区二区三区 | 黄色国产区| 国产视频一二三区 | 国产一区二区久久 | 亚洲精品综合 | 国产成人精品在线 | 国产99小视频 | 国产一区二区三区在线 | 人人玩人人干 | 久久精品视频网站 | 999久久久国产精品 欧美成人h版在线观看 | 精品影视 | 欧美日韩一区二区视频在线观看 |