我試圖發送一個網頁作爲電子郵件。此網頁的內容基於變量,這些變量使用_GET方法調用。如何使用file_get_contents發送變量?
我有這部分的代碼,如果我沒有在網址中加入任何變量,但在我寫?variable=
後立即回覆[function.file-get-contents]: failed to open stream: No such file or directory in...
。
<?
$var_one = $_GET['var_one'];
$var_two = $_GET['var_two'];
$from = "Company name";
$from_email = "[email protected]";
$email_text = file_get_contents("mail_this_page.php?varone=".$var_one."&vartwo=".$var_two);
$headers = "From:[email protected]";
$headers = "From: $from <$from_email>\r\n".
"MIME-Version: 1.0" . "\r\n" .
"Content-type: text/html; charset=UTF-8" . "\r\n";
mail('[email protected]', 'Hello', $email_text, $headers);
?>
所以,問題是在file_get_contents
行。
$email_text = file_get_contents("mail_this_page.php");
作品,但
$email_text = file_get_contents("mail_this_page.php?varone=".$var_one."&vartwo=".$var_two);
沒有。我究竟做錯了什麼?我怎樣才能使用這種方法傳遞變量?
您是否看到http://stackoverflow.com/questions/7352832/get-request-from-php-using-file-get-contents-with-parameters? – FBHY
是的,嘗試過使用單引號和雙引號等多種解決方案,都給出了相同的結果 –