本文整理汇总了PHP中sfValidatorBase::getCharset方法的典型用法代码示例。如果您正苦于以下问题:PHP sfValidatorBase::getCharset方法的具体用法?PHP sfValidatorBase::getCharset怎么用?PHP sfValidatorBase::getCharset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfValidatorBase
的用法示例。
在下文中一共展示了sfValidatorBase::getCharset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getArguments
/**
* Returns the arguments needed to format the message.
*
* @param bool $raw false to use it as arguments for the message format, true otherwise (default to false)
*
* @see getMessageFormat()
*/
public function getArguments($raw = false)
{
if ($raw) {
return $this->arguments;
}
$arguments = array();
foreach ($this->arguments as $key => $value) {
if (is_array($value)) {
continue;
}
$arguments["%{$key}%"] = htmlspecialchars($value, ENT_QUOTES, sfValidatorBase::getCharset());
}
return $arguments;
}
示例2: array
$t->diag('->setMessages()');
$v->setMessages(array('required' => 'This is required!'));
$t->is($v->getMessages(), array('invalid' => 'Invalid.', 'required' => 'This is required!'), '->setMessages() changes all error messages');
// ->addMessage()
$t->diag('->addMessage()');
$v->addMessage('foobar', 'foo');
$v->setMessage('foobar', 'bar');
$t->is($v->getMessage('foobar'), 'bar', '->addMessage() adds a new error code');
// ->getErrorCodes()
$t->diag('->getErrorCodes()');
$t->is($v->getErrorCodes(), array('required', 'invalid', 'foo'), '->getErrorCodes() returns an array of error codes the validator can use');
// ::getCharset() ::setCharset()
$t->diag('::getCharset() ::setCharset()');
$t->is(sfValidatorBase::getCharset(), 'UTF-8', '::getCharset() returns the charset to use for validators');
sfValidatorBase::setCharset('ISO-8859-1');
$t->is(sfValidatorBase::getCharset(), 'ISO-8859-1', '::setCharset() changes the charset to use for validators');
// ->asString()
$t->diag('->asString()');
$v = new ValidatorIdentity();
$t->is($v->asString(), 'ValidatorIdentity()', '->asString() returns a string representation of the validator');
$v->setOption('required', false);
$v->setOption('foo', 'foo');
$t->is($v->asString(), 'ValidatorIdentity({ required: false, foo: foo })', '->asString() returns a string representation of the validator');
$v->setMessage('required', 'This is required.');
$t->is($v->asString(), 'ValidatorIdentity({ required: false, foo: foo }, { required: \'This is required.\' })', '->asString() returns a string representation of the validator');
$v = new ValidatorIdentity();
$v->setMessage('required', 'This is required.');
$t->is($v->asString(), 'ValidatorIdentity({}, { required: \'This is required.\' })', '->asString() returns a string representation of the validator');
// ::setDefaultMessage()
$t->diag('::setDefaultMessage()');
ValidatorIdentity::setDefaultMessage('required', 'This field is required.');