在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