1

I can't figure out how to include a variable inside an HTML link; this link is itself a variable. My quotation marks work fine until I try to add $ou. Any ideas?

$mout = '<img src="http://www.example-website.com/header.jpg" width="600px" height="101px" alt="header" /><br />Click on the following link to confirm your registration:<br /><a href="Http://example-website.com/coupon.php?o=' . $ou'">Confirm</a>';

4 Answers 4

6
$mout = '<img src="http://www.example-website.com/header.jpg" width="600px" height="101px" alt="header" /><br />Click on the following link to confirm your registration:<br /><a href="Http://example-website.com/coupon.php?o=' . $ou . '">Confirm</a>';
Sign up to request clarification or add additional context in comments.

Comments

2

Although the above examples are perfectly fine, when using double quotes you can include variables in the string, for example:

$foo = "bar";

echo "This is a variable: $foo";

will output:

This is a variable: bar

However with single quotes you are required to close the quotes and append the variable like so:

echo 'This is a variable: ' . $foo;

Also, using remember you can escape quotes with a backslash within a string if you want them to be included.

For example:

$foo = "This string contains \"Double-Quotes!\"";

echo $foo;

Would output

This string contains "Double-Quotes!";

Comments

1

You forgot . after your variable:

' . $ou . '

Comments

1
'...coupon.php?o='.$ou.'">Confirm</a>';

you're missing a dot

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.