Possible Duplicate:
开发者_Python百科PHP: Cannot assign string value to variable
if($page_name == "home"){
$header_text = "<a href="http://www.mysite.com/d">. $category .</a>";
}
how to fix it
First echo out $header_text = "<a href="http://www.mysite.com/d">. $category .</a>";
And then try to echo out $header_text = "<a href=\"http://www.mysite.com/d\"> $category </a>";
or $header_text = '<a href="http://www.mysite.com/d">'. $category .'</a>';
.
Note in the first case, you have got error, and you will not get results.
Try
if($page_name == "home"){
$header_text = '<a href="http://www.mysite.com/d">'. $category .'</a>';
}
if($page_name == "home") {
$header_text = "<a href=\"http://www.mysite.com/d\">. $category .</a>";
}
You need to escape your quotes. Any time you want to have a character that also has a symbolic meaning it needs to be escaped to use its literal meaning.
Read more on escape sequences here: http://en.wikipedia.org/wiki/Escape_character
Check the following code:
if($page_name=="home")
{
$header_text = '<a href="http://www.mysite.com/d">'. $category .'</a>';
// Or, $header_text = "<a href='http://www.mysite.com/d'>$category</a>";
}
精彩评论