本文整理匯總了PHP中Valid::alpha_dash方法的典型用法代碼示例。如果您正苦於以下問題:PHP Valid::alpha_dash方法的具體用法?PHP Valid::alpha_dash怎麽用?PHP Valid::alpha_dash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Valid
的用法示例。
在下文中一共展示了Valid::alpha_dash方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: test_alpha_dash
/**
* Tests Valid::alpha_dash()
*
* Checks whether a string consists of alphabetical characters, numbers, underscores and dashes only.
*
* @test
* @dataProvider provider_alpha_dash
* @param string $input The string to test
* @param boolean $contains_utf8 Does the string contain utf8 specific characters
* @param boolean $expected Is $input valid?
*/
public function test_alpha_dash($input, $expected, $contains_utf8 = FALSE)
{
if (!$contains_utf8) {
$this->assertSame($expected, Valid::alpha_dash($input));
}
$this->assertSame($expected, Valid::alpha_dash($input, TRUE));
}
示例2: check_data
public static function check_data($value, $data)
{
switch ($data['type']) {
case 'static':
return TRUE;
case 'module':
return Valid::not_empty($value) and Valid::alpha_dash($value) and $value != '-';
case 'page':
return Valid::not_empty($value) and Valid::digit($value) and $value != '-' and $data['id'] != $value;
case 'url':
return Valid::not_empty($value) and Model_Page::check_link($value) and $value != '-';
}
return FALSE;
}
示例3: after
/**
* Output response.
*/
public function after()
{
switch ($this->format) {
// Support JSON and JSONP
case self::FORMAT_JSON:
$this->response->headers('Content-Type', 'application/json');
// Check and sanitize JSONP
$jsonp = Arr::get($_REQUEST, 'callback');
if ($jsonp && Valid::alpha_dash($jsonp)) {
$this->response->body($jsonp . '(' . json_encode($this->data) . ')');
} else {
$this->response->body(json_encode($this->data));
}
break;
case self::FORMAT_XML:
$this->response->headers('Content-Type', 'application/xml');
$this->response->body(Arr::xml($this->data));
break;
}
}