fopen、getimagesize、include 等函式若要開啟 HTTP/HTTPS URL,需滿足三個條件。
allow_url_fopen = On
allow_url_include = On ; 若需 include/require 遠端檔案
修改後重啟 PHP-FPM/Apache。
Windows 下 fopen('https://localhost/...') 常卡住逾時,換成 127.0.0.1 即正常。原因是 hosts 檔案未生效。
編輯 C:\Windows\System32\drivers\etc\hosts,確保有:
127.0.0.1 localhost
移除前方 # 號,存檔即時生效。
setenforce 0。/etc/selinux/config 設 SELINUX=disabled 重啟。$content = file_get_contents("compress.zlib://https://example.com");
或改用 cURL 完整支援協議、驗證、代理等。
<?php include 'https://domain.com/inc.php?foo=1&bar=2'; ?>
// inc.php 內可直接用 $_GET['foo']、$_GET['bar']
allow_url_fopen = On?127.0.0.1 替代 localhost?