Link to home
Start Free TrialLog in
Avatar of Luey
LueyFlag for United States of America

asked on

proper way to write a php variable with a hyperlink

Can someone tell me the correct way to write this variable.

 $mess .= "<a href=".$_POST['email_site_address'].">".$_POST['email_site_name']."</a>";
Avatar of Hugh McCurdy
Hugh McCurdy
Flag of United States of America image

I don't understand the question.  Perhaps a question from me will help -- Where do you want to write the variable?
Avatar of Luey

ASKER

Well actually it works but I do not understand why.
Normally you would write a hyperlink like so right?
<a href="some_site">"some text"</a>

With my variable would I not be missing the "" around the site address after href=
"<a href=".$_POST['email_site_address'].">".$_POST['email_site_name']."</a>
ASKER CERTIFIED SOLUTION
Avatar of Hugh McCurdy
Hugh McCurdy
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ray makes a good point about striving for better code.

The var_dump is a very good idea.  Regardless of what you do, if you are still having trouble, please share the var_dump of $mess with us.
If using Ray's code, also the var_dump of $e and $n.
And a var_dump($_POST) might be a helpful and informative step, as well!
Avatar of Luey

ASKER

Both examples worked but I ended up using the HEREDOC syntax.  Thanks a lot.