2011-03-29 32 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