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.

Answers


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>";

This code will help you out:

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

Note the double quotes (") between the string concatenation (') this is needed by the browser to make render the proper href element.


Need Your Help

EJB Overriding JPA javax.persistence

java hibernate jpa ejb guice-persist

I'm fairly new to the Java EE space, so pardon my ignorance here; I inherited an application which is using guice-persist and hibernate to handle the ORM.

Eclipse give error in my project

eclipse

I think that my Eclipse is trying to destroy my brain.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.