我有腳本在絕大多數地區使用絕對地址,現在我需要將它們改爲相對地址。但後來我在這裏面臨的問題是,如果例如我有一個名爲替換php鏈接到靜態鏈接
www.example.com網站現在我想從
<link href="<?php print $theme; ?>style.css" type="text/css" rel="stylesheet" />
<link href="<?php print $theme; ?>css/colorpicker.css" type="text/css" rel="stylesheet" />
改變PHP的鏈接
<link href="http://www.example.com/<?php print $theme; ?>style.css" type="text/css" rel="stylesheet" />
<link href="http://www.example.com/<?php print $theme; ?>css/colorpicker.css" type="text/css" rel="stylesheet" />
但我最終得到這個結果
<link href="http://www.example.com/http://www.example.com/themes/in/style.css" type="text/css" rel="stylesheet" />
<link href="http://www.example.com/http://www.example.com/themes/in/css/colorpicker.css" type="text/css" rel="stylesheet" />
我知道什麼是錯的地方,但我仍然無法得到它的工作。與正確的格式任何幫助將得到高度讚賞。對不起,如果我的題目是不恰當的。
刪除''??php print $ theme; ?>'從你的鏈接代碼。 – Rikesh
您應該檢查'$ theme'變量中的內容以及爲什麼 – Voitcus
@Chris:請確保您沒有在「$ theme」vairbale中包含基本路徑? – Suleman