PHP IF函数重定向

why does my page redirect to www.mysite/user/<?php echo $id; ?>

when my code is:

<?php 
$id= $_GET['id'];
$con= $_GET['con'];
?>

and

<?php endif; ?>
<?php if ($con == ''): ?>
<?php
header('Refresh: 5; URL=http://www.youtube.com/subscription_center?add_user=<?php echo $id; ?>');
?>
<?php endif; ?>

it's suppose to redirect to whatever ID equals in the address bar

Change this:

header('Refresh: 5; URL=http://www.youtube.com/subscription_center?add_user=<?php echo $id; ?>');

To:

header('Refresh: 5; URL=http://www.youtube.com/subscription_center?add_user=' . $id );

In your version <?php echo $id; ?> is part of the header string.

You are opening two php tags, one inside another while you should concatenate, just change as follow

header('Refresh: 5; URL=http://www.youtube.com/subscription_center?add_user='.$id);
                                                                          //^ here

Try this:

header('Refresh: 5; URL=http://www.youtube.com/subscription_center?add_user='.$id);