php include()帶參數實現方法_PHP教程

來源:互聯網
上載者:User
inlcude帶參數這個問題以前我沒成功,今天看到一文章果斷搞了了,如我可以這樣include(\'a.php?site=www.bKjia.c0m\')然後在調用a.php頁面可直接$_GET[\'a\'];擷取了。

具體方法詳解


舉例:假設在 index.php 中需要調用 inc.php?para=3 ,

inc.php

代碼如下 複製代碼

下面的寫法是無法得到正確結果的:

index.php

代碼如下 複製代碼

稍微變通一下,把$_GET變數在include之前定義,則可以正常運行:
index.php

代碼如下 複製代碼

如果php.ini中開啟了allow_url_include功能,則可以使用include url的方式:
index.php

代碼如下 複製代碼

設定方法:php.ini中,找到如下行,改為On:

; Whether to allow include/require to open URLs (like http:// or ftp://) as files.
allow_url_include = On

不過為了保證安全性,大部分的伺服器都將allow_url_include 功能關閉,那樣就只能視情況而定了。

http://www.bkjia.com/PHPjc/628731.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/628731.htmlTechArticleinlcude帶參數這個問題以前我沒成功,今天看到一文章果斷搞了了,如我可以這樣include(\'a.php?site=www.111cn.net\')然後在調用a.php頁面可直接$_G...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.