在PHP我有一個功能PHP - 傳遞變量
ob_start();
echo "<p>Your Feed URL - <a href='/blah'>Click Here</a></p>";
$feedURL = ob_get_contents();
ob_end_clean();
現在這個存儲我的ECHO爲名爲$ feedURL一個局部變量,我需要在我的PHP腳本的另一部分使用這個變量的代碼。每次發佈表單時都會生成echo語句。我需要的是當表單被POST時,所創建的變量可以在函數的腳本的另一部分中使用。
我試過使用return $ var;
當我然後嘗試echo $ var在一個單獨的函數它返回一個空字符串?
我是愚蠢的還是有我失蹤的東西?
我想在這個其他函數中使用該變量。
function add_page_content_Send_Feed(){
echo "<h2>Send your feed via email</h2>";
echo "<p>Below you can send your feed URL. Just enter the email you wish to send to.</p>";
echo "<p>This email will contain the URL leading to your feed</p>";
echo "<form id='post' action='http://localhost/wp/ultrait/admin.php?page=page6' method='POST'>";
echo "<label for='email'>Email:</label> <br /> <input type ='text' value = '' name = 'email' id = 'email'/><br /><br />";
echo "<input type='submit' name='send_feed' value='Send my feed' id='submit'/>";
echo "</form>";
// Example using the array form of $headers
// assumes $to, $subject, $message have already been defined earlier...
$headers[] = 'From: UltraIT <[email protected]>';
$subject = 'Feed URL from UltraIT Property Management';
$test = "blah";
$message = 'Hello, please see your feed URL below. ' . $test;
if(isset($_POST['send_feed'])){
if(empty($_POST['email'])) // If no email has been specified
{
echo "<p>Please enter an Email</p>";
}
else{
$email = $_POST['email'];
print ($email);
}
$to = $email;
wp_mail($to, $subject, $message, $headers);
}}
我需要的變量是$消息變量的值。
顯示你的代碼,以及如何使用您的話,那麼我們也許能夠幫助你。 – NoLiver92