Search code examples
phphtmlhref

Using php variable in href html links


here is what i am trying to do

 $store='something.com';
 echo  '<div><h3>click on</h3><a href='.$store.'>host</a></p></div>';

what it output is

something.com

instead it should use something.com as link and output need to be host.

try for sometime to do it my own but havn't achieved any success.


Solution

  • I am agree with the Answer of Ma'moon and it is right.

    Php code does not work inside the single quotes ' ', so its required to place code inside the double quotes " ".

    You can also use following method instead ↓

    $store='something.com';
    echo  "<div><h3>click on</h3><a href='$store'>host</a></p></div>";