How to use php variable in html href | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to use php variable in html href

<input type="text" name="example"> <?php $ex = $_REQUEST['example']; ?> <a href="http://example.com/number=<?php $ex ?>"> it only show http://example.com/number= how to fix it so the $ex will be combine with link ?

30th Mar 2019, 4:41 PM
Kenzo Akbar
Kenzo Akbar - avatar
2 Answers
+ 2
Try to echo the variable value. It seems your anchor tag was not closed, don't forget to close the anchor tag. <a href="http://example.com/number=<?php echo $ex; ?>">The hyperlink text</a> Is there a specific reason for using $_REQUEST opposed to $_POST or $_GET?
30th Mar 2019, 7:39 PM
Ipang
0
juste make<a href="<?= $your_variable ?>" >exemple</a>
1st Apr 2019, 11:21 AM
Onadja Soanguimpali Clovis Jerôme
Onadja Soanguimpali Clovis Jerôme - avatar