how to make hyperlink of a PHP variable into a PHP block?

  • Thread starter Thread starter Stormovik
  • Start date Start date
S

Stormovik

Guest
hello,
I'm trying to make a hyperlink in a PHP block,
like this <? php print '<A HREF="link.PHP">$A</A>'; ,,, ?>
it works, but the problem is that $A is a PHP variable containg data from a database, like a phone number ( $A=$Ligne['Num_tel']; ), the result is that the link is only the "$A" in blue underlined, but I want to see what is inside ! please help how to solve this problem, if i can make the PHP variable get out from the PHP block so I can use it in HTML language; thank you
 
Two options (for ease of use):
<? php echo "<A HREF='link.php'>$A</A>'; ?>

OR

<A HREF="link.php"><? php echo $A; ?>

You can also use printf (as previously answered). If this is in a block of HTML, then you should use the second method for readability. If you are outputting all of the HTML via echo or printf, then the first method is what you should use.
 
<a href="link.php"><?php echo($a); ?></a>
or you could do
<?php
printf('<a href="link.php">%s</a>',$a);
?>


If you want to embed php in html you need to Surround it in <?php ?>
and if you want to print a variable you need to use
echo $a;
or
echo($a);
The () are optional i use them because if find it easier to read.
or you can use printf it lets you insert variable values into a string its useful for SQL.

NB html tags should be lowercase always.
 
Back
Top