user3568791
user3568791

Reputation: 716

How to put variable value in a href?

This question may sound banal, but I'm really new to php. I have:

<?php $kzl="pencho"; ?>

<a href="settings.php?var=$kzl">asdf</a>

in the script settings.php

<? echo &_GET['var']; ?>

and on the screen is printed kzl not the value in kzl, why ?

Upvotes: 1

Views: 1284

Answers (3)

deemi-D-nadeem
deemi-D-nadeem

Reputation: 2514

You should call variable in PHP Block

<a href="settings.php?var=<?php echo $kzl; ?>">asdf</a>

Upvotes: 0

H&#252;seyin BABAL
H&#252;seyin BABAL

Reputation: 15550

You need to print value of $kzl in url. Use this;

<a href="settings.php?var=<?php echo $kzl;?>">asdf</a>

Or you can use;

echo '<a href="settings.php?var=' . $kzl . '">asdf</a>';

Upvotes: 4

Pupil
Pupil

Reputation: 23948

Its because you are not doing it the right way.

Do it:

 <a href="settings.php?var=<?php echo $kzl;?>">asdf</a>

Upvotes: 0

Related Questions