I’ve got this piece of code:
<?php
$userid = $me['id'];
function showifuserexists() {
?>
<html>
<head></head>
<body>
<a href="file.php?element1=aaa&userid=<?php print $userid; ?>">
</body>
</html>
<?php
}
?>
For some reason I can’t get the php $userid to show up in the html link. I’ve tried echo too. Help?
You should read up on variable scope.
$useridin your function is not the same as$useridoutside of your function – it has a differentscope. You could make the variable global, but that’s not really good practice, especially in this context.I’m not really sure what you are trying to achieve; but I guess..
then you would do:
for example. But your requirements aren’t really that clear.