开发者

Fixing code php mysql [duplicate]

开发者 https://www.devze.com 2023-02-20 06:34 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: 开发者_Python百科PHP: Cannot assign string value to variable
This question already has answers here: Closed 11 years ago.

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

精彩评论

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