PHP - 传递变量

In PHP I have this code in a function

 ob_start();
        echo "<p>Your Feed URL - <a href='/blah'>Click Here</a></p>";
        $feedURL = ob_get_contents();
        ob_end_clean();

Now this stores my ECHO as a local variable called $feedURL, I need to use this variable in another part of my PHP script. The echo statement is generated each time I post a form. What I need is when a form is POSTed, the variable created can then be used in another part of the script within a function.

I have tried using return $var;

When I then tried echo $var in a seperate function it returned an empty string?

Am I being stupid or is there something I'm missing?

I want to use the variable in this other function.

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 <demo@ultrait.org>';
$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);

} }

I need the variable to be the value of the $message variable.

To access it from any function you can use global keyword, but its not a good practice, use function param to keep your code loose coupled.

function myFunc() {
    global $feedURL;
    //then use it 
}

make sure you have included above file on top.

Update

you need to pass $feedURL as argument in you function

add_page_content_Send_Feed($feedURL) {
  ...
  $message = 'Hello, please see your feed URL below. ' . $feedURL;
  ...
}