我在包含php變量的Mysql表中有一個字段,用於確定存儲文件的目錄(例如,Docs/$CompID/
和Acc/$AccID/
)。問題是,當我檢索值時,顯示php變量名稱而不是值。在mysql字段中使用php變量
我試圖放置引號值 -
無論在MySQL表(Docs/$CompID/"
和Docs/".$CompID."/
)
並顯示PHP變量時(echo"$dir"
)
我還試圖做str_replace
,將{ }
放在變量的周圍,以便我可以在字符串中標識它:
$start=strrpos($cat['dir'],'{');
$stop=strrpos($cat['dir'],'}');
$rep=substr($cat['dir'],$start+1,$stop-1);
$dir=str_replace("{".$rep."}",$rep,$cat['dir']);
所有這些只顯示php變量名稱。任何幫助,將不勝感激!
是什麼'$貓[ '目錄']'是什麼樣子? –
Docs/$ CompID /和Acc/$ AccID /是$ cat ['dir']中數據類型的示例。當我嘗試使用str_replace時,我將它們更改爲Docs/{$ CompID} /和Acc/{$ AccID}/... – Alan