2011-03-29 66 views
1
if($page_name == "top_sites"){ 

$page_text = "<a href="http://www.mysite.com/top-site">Top 200</a>"; 
} 

此代码不能正常工作 请帮我纠正PHP:不能字符串值赋给变量

+1

为什么使用mysql标签?这个问题与mysql无关! – 2011-03-29 09:35:36

回答

4

你需要逃避你"

所以只是把\在他们面前:

$page_text = "<a href=\"http://www.mysite.com/top-site\">Top 200</a>"; 

或者,您可以在字符串周围使用单引号:

$page_text = '<a href="http://www.mysite.com/top-site">Top 200</a>'; 
+0

$ header_title =“. $category .”; 如何解决这个问题? – Hassan 2011-03-29 09:40:15

+0

您只需要在将它与另一个连接起来之前关闭该字符串:“".$category."” – 2011-03-29 10:29:51

+0

对不起,忘记在您的href中转义引号。 – 2011-03-29 10:30:41

0
if($page_name == "top_sites"){ 

    $page_text = '<a href="http://www.mysite.com/top-site">Top 200</a>'; 

} 
+0

$ header_text =“//”. $category .“//”。 $标题2。 “壁纸”; – Hassan 2011-03-29 09:37:56

+0

如何解决这个 – Hassan 2011-03-29 09:39:00

+0

$ header_text =“. $category .”; – Hassan 2011-03-29 09:39:26