[英]Replace “ with \” with Doctrine 1.2
這是我的問題。
我使用 Doctrine 1.2 從數據庫中獲取數據並將數據放入文本框中。
數據為 19" x 12" 放入文本框
結果如下:
<input type="text" value="19" x 12"" />
我想我需要逃避所有的“與\”
我的問題是:如何在不進入所有腳本並創建 str_replace() 的情況下自動執行此操作?
感謝大家。
我只會使用htmlentities
$string = htmlentities($text_with_quotes, ENT_QUOTES);
echo '<input type="text" value="' . $string . '">';
應該給你你需要的。
看看htmlspecialchars ,應該可以解決問題。
您可以在 model class 中編寫您的 function :
public function getInputValue() {
return addslashes($this->_get('table_field_name'));
}
然后在您的視圖中使用。 或者您可以覆蓋從具體表字段獲取數據的 function:
public function getFieldname() {
return addslashes($this->_get('table_field_name'));
}
addlashes 可以替換為您想要在視圖中獲取實際需要的數據的任何內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.