0
版本1: 我有這個代碼的作品,以及:爲什麼file_get_contents()在沒有協議的情況下無法工作?
file_put_contents("../img/avatar/".$id.".jpg", file_get_contents("http://localhost/folder/script.php?id=$id"));
版本2:現在我需要寫沒有協議的路徑file_get_contents
,因此,這裏是我的代碼的新版本。但它不起作用:
$_GET['id'] = $id;
file_put_contents("../img/avatar/".$id.".jpg", file_get_contents("../folder/script.php"));
版本2有什麼問題?
注:script.php
使一個頭像。並且版本1也會創建該圖像,但版本2只會創建未知圖像。
'file_get_contents()'不解釋PHP代碼,它只是讀取文件。它通過'http://'隧道傳輸的原因是因爲你的http服務器解釋它,並返回結果。 – Havenard
http://php.net/manual/en/function.error-reporting.php –
@ Fred-ii-沒有錯誤。剛剛保存的照片是未知的。 – stack