2011-01-28 27 views
-2

我需要在哪裏放置關鍵字信息才能讓功能在存儲變量中動態抓取它?我已閱讀關於如何創建關鍵字功能以自動將關鍵字放入PHP的文章

function get_headers() { 
    // here set $title, $description and $keywords according to current page 
    // .... 

    // then just generate html 
    $html = "<title>$title</title>"; 
    $html .= "<meta name='description' content='$description' />"; 
    $html .= "<meta name='keywords' content='$keywords' />"; 

    return $html; 
} 

我希望那不是太笨蛋。笑

+0

你動態地說,但暗示有一些來源比打字它的其他關鍵字數據這個代碼你自己。這是什麼來源?數據庫中是否有關鍵字?你把它們放在一個文本文件中嗎?換句話說,這個「動態」信息應該從哪裏來? – 2011-01-28 03:33:14

+0

對不起,我沒有明白你的意思。當然你發佈的代碼片段應該足夠了嗎? – evandrix 2011-01-28 03:34:07

回答

0

如果您使用它更有意義,通過這些入函數作爲參數的函數:

function get_headers($title, $description, $keywords) { 

    // then just generate html 
    $html = "<title>$title</title>"; 
    $html .= "<meta name='description' content='$description' />"; 
    $html .= "<meta name='keywords' content='$keywords' />"; 

    return $html; 
}