开发者

Php variable inside HTML that is a variable

开发者 https://www.devze.com 2023-03-26 09:18 出处:网络
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?

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>';开发者_C百科


$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>';


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


You forgot . after your variable:

' . $ou . '


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

you're missing a dot

0

精彩评论

暂无评论...
验证码 换一张
取 消