开发者

Retain quotation marks in Zend .ini config

I am building a website and I require quotation marks in a configuration value.

Example:

convert_arg = -resize "1000x1000>" -strip -trim +repage -density 72x72 -sampling-factor 4:2:0 -quality 70

This particular configuration item is the command-line arguments to call Imagemagick's convert utility. The quotation marks tell the command-line not to consider '>' as the pipe comm开发者_如何学Goand. However, Zend appears to strip these characters from the value, so it tries to pipe the subsequent error to a file called -strip.

Can this be disabled or worked around? Thanks.


As this question hasn't been answered in a while, I figure I will respond with my work-around. It's not ideal, but it works and is not too difficult to implement.

It involves declaring a constant which will represent the quotation mark, as Zend_Config (Which uses the parse_ini_file() function) will interpret PHP constants.

In www/index.php we declare the constant:

// Define _Q to be a quotation mark
defined('_Q') || define('_Q', '"');

In application.ini we use the constant in place of quotation marks:

my.config.key = "my config value can now contain " _Q "quotation marks" _Q "!"

So now, in your code, the value of my.config.key is now:

my config value can now contain "quotation marks"!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜