开发者

Replace " with \" with Doctrine 1.2

Here is my problem.

I get data from database using Doctrine 1.2 and put the data in a Textbox.

The data is 19" x 12" to put in the Textbox

Here is the result:开发者_开发知识库

<input type="text" value="19" x 12"" />

I think I need to escape all the " with \"

My question is : How can I perform this automaticly without going into all my script and make a str_replace() ?

Thanks everyone.


I would just use htmlentities

$string = htmlentities($text_with_quotes, ENT_QUOTES);
echo '<input type="text" value="' . $string . '">';

Should give you what you need.


Have a look at htmlspecialchars, that should solve the issue.


You can write your function in model class like:

public function getInputValue() {
    return addslashes($this->_get('table_field_name'));
}

And then use in your views. Or you can override function that gets data from concrete table field:

public function getFieldname() {
    return addslashes($this->_get('table_field_name'));
}

addslashes can be replaced by whatever you want to get actually needed data in the views.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜