How to add PHP variables to a href url

href, html, php

Solution

Try this,

<?php
@session_start();
$uid= $_SESSION['userid'];
?>
<a href="http://example.com/?uid=<?php echo $uid; ?>" >Your link text</a> 

Problem

Im trying to add a PHP variable to a href url This is the code: PHP ``` $uid= $_SESSION['userid']; ``` HTML ``` <a href=http://example.com/uid= <?php echo ".$uid."?> /a> ``` How do you add, when I do it, this is what it redirect too: http://example.com/uid=.

Original source