本文整理汇总了PHP中ctype_graph函数的典型用法代码示例。如果您正苦于以下问题:PHP ctype_graph函数的具体用法?PHP ctype_graph怎么用?PHP ctype_graph使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ctype_graph函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* @inheritdoc
*/
public function validate($input)
{
if (!is_scalar($input) || $input === '') {
return false;
}
$input = str_replace(str_split($this->params['additionalChars']), '', (string) $input);
return $input === '' || ctype_graph($input);
}
示例2: dump
/**
* @en Converts stream bytes into the array of numeric equivalents (or ASCII if you want so)
* @ru Возвращает дамп в виде массива числовых значений (также может подбирать ASCII)
*
* $stream = "ABC1234\0";
*
* $dump = stream::dump($stream); # Array
* # (
* # [0] => 65 # equals ASCII dec `A`
* # [1] => 66 # equals ASCII dec `B`
* # [2] => 67 # equals ASCII dec `C`
* # [3] => 49 # equals ASCII dec `1`
* # [4] => 50 # equals ASCII dec `2`
* # [5] => 51 # equals ASCII dec `3`
* # [6] => 52 # equals ASCII dec `4`
* # [7] => 0 # equals ASCII dec `\0`
* # )
*
* $dump = stream::dump($stream, true); # Array
* # (
* # [0] => 41 # equals ASCII hex `A`
* # [1] => 42 # equals ASCII hex `B`
* # [2] => 43 # equals ASCII hex `C`
* # [3] => 31 # equals ASCII hex `1`
* # [4] => 32 # equals ASCII hex `2`
* # [5] => 33 # equals ASCII hex `3`
* # [6] => 34 # equals ASCII hex `4`
* # [7] => 0 # equals ASCII hex `\0`
* # )
*
* $dump = stream::dump($stream, true, true); # Array
* # (
* # [0] => A
* # [1] => B
* # [2] => C
* # [3] => 1
* # [4] => 2
* # [5] => 3
* # [6] => 4
* # [7] => 00
* # )
*
* @param string $stream
* @param bool $hexdump
* @param bool $decode_printable
*
* @return array
*/
public static function dump($stream, $hexdump = false, $decode_printable = false)
{
$byte_array = string::explode($stream);
$result = null;
foreach ($byte_array as $byte) {
if ($decode_printable !== false) {
if (ctype_graph($byte)) {
$result[] = $byte;
continue;
}
}
if ($hexdump !== false) {
$result[] = bin2hex($byte);
continue;
}
$result[] = ord($byte);
}
return $result;
}
示例3: ctype_graph
<?php
/* Prototype : bool ctype_graph(mixed $c)
* Description: Checks for any printable character(s) except space
* Source code: ext/ctype/ctype.c
*/
/*
* Pass octal and hexadecimal values to ctype_graph() to test behaviour
*/
echo "*** Testing ctype_graph() : usage variations ***\n";
$orig = setlocale(LC_CTYPE, "C");
$octal_values = array(061, 062, 063, 064);
$hex_values = array(0x31, 0x32, 0x33, 0x34);
echo "\n-- Octal Values --\n";
$iterator = 1;
foreach ($octal_values as $c) {
echo "-- Iteration {$iterator} --\n";
var_dump(ctype_graph($c));
$iterator++;
}
echo "\n-- Hexadecimal Values --\n";
$iterator = 1;
foreach ($hex_values as $c) {
echo "-- Iteration {$iterator} --\n";
var_dump(ctype_graph($c));
$iterator++;
}
setlocale(LC_CTYPE, $orig);
?>
===DONE===
示例4: _WT
<?php
require_once 'init.php.inc';
if (function_exists('ctype_graph')) {
$this->isTrue(ctype_graph('fjsdiopfhsiofnuios'), _WT('Original ctype_graph fails to validate random letters.'));
$this->isTrue(ctype_graph('FELMNFKLFDSNFSKLFNSDL'), _WT('Original ctype_graph fails to validate random uppercase letters.'));
$this->isTrue(ctype_graph('0123456789azertyuiopqsdfghjklmwxcvbn'), _WT('Original ctype_graph fails to validate [0-9a-z].'));
$this->isTrue(ctype_graph('5686541641'), _WT('Original ctype_graph fails to validate random numbers.'));
$this->isTrue(ctype_graph('5A1C9B3F'), _WT('Original ctype_graph fails to validate random hexadecimal numbers.'));
$this->isTrue(ctype_graph('0123456789azertyuiopqsdfghjklmwxcvbn?'), _WT('Original ctype_graph fails to validate [0-9a-z?].'));
$this->isTrue(ctype_graph('1.5'), _WT('Original ctype_graph fails to validate a float number.'));
$this->isTrue(ctype_graph('?*#'), _WT('Original ctype_graph fails to validate punctuation.'));
$this->isFalse(ctype_graph("\r\n\t"), _WT('Original ctype_graph returns true for control characters.'));
$this->isFalse(ctype_graph(' '), _WT('Original ctype_graph returns true for a space.'));
$this->isFalse(ctype_graph(''), _WT('Original ctype_graph returns true for the empty string.'));
$this->isFalse(ctype_graph(null), _WT('Original ctype_graph returns true for a null value.'));
}
$this->isTrue(emul_ctype_graph('fjsdiopfhsiofnuios'), _WT('Emulated ctype_graph fails to validate random letters.'));
$this->isTrue(emul_ctype_graph('FELMNFKLFDSNFSKLFNSDL'), _WT('Emulated ctype_graph fails to validate random uppercase letters.'));
$this->isTrue(emul_ctype_graph('0123456789azertyuiopqsdfghjklmwxcvbn'), _WT('Emulated ctype_graph fails to validate [0-9a-z].'));
$this->isTrue(emul_ctype_graph('5686541641'), _WT('Emulated ctype_graph fails to validate random numbers.'));
$this->isTrue(emul_ctype_graph('5A1C9B3F'), _WT('Emulated ctype_graph fails to validate random hexadecimal numbers.'));
$this->isTrue(emul_ctype_graph('0123456789azertyuiopqsdfghjklmwxcvbn?'), _WT('Emulated ctype_graph fails to validate [0-9a-z?].'));
$this->isTrue(emul_ctype_graph('1.5'), _WT('Emulated ctype_graph fails to validate a float number.'));
$this->isTrue(emul_ctype_graph('?*#'), _WT('Emulated ctype_graph fails to validate punctuation.'));
$this->isFalse(emul_ctype_graph("\r\n\t"), _WT('Emulated ctype_graph returns true for control characters.'));
$this->isFalse(emul_ctype_graph(' '), _WT('Emulated ctype_graph returns true for a space.'));
$this->isFalse(emul_ctype_graph(''), _WT('Emulated ctype_graph returns true for the empty string.'));
$this->isFalse(emul_ctype_graph(null), _WT('Emulated ctype_graph returns true for a null value.'));
示例5: validOtp
/**
* Validate a string as a one-time-password.
* A valid OTP should consist of 32-48 printable characters.
*
* @param string $otp
* String to Validate
*
* @return boolean
* True if the OTP is valid, false on error.
*/
public function validOtp($otp)
{
$length = strlen($otp);
/* Check length. */
if ($length > 48 || $length < 32) {
return false;
}
/* Check for printable charcters (no whitespace). */
return ctype_graph($otp);
}
示例6: hasGraphicalCharsOnly
/**
* @param string $value
*
* @return bool
*/
public static function hasGraphicalCharsOnly($value)
{
return \ctype_graph($value);
}
示例7: isSingleline
public static function isSingleline($data, $options = array())
{
return ctype_graph($data);
}
示例8: _passwordHash
private function _passwordHash(&$data, $value)
{
$data['passwordHash'] = ctype_graph($value) && strlen($value) >= 60 ? $value : '';
}
示例9: isVisible
/**
* Determine whether all characters in a string are visible characters.
*
* Whitespace and control characters are not visible characters.
*
* @param string $s
* @return bool Returns `false` if `$s` is empty.
*/
public static function isVisible($s)
{
return ctype_graph($s);
}
示例10: isGraph
/**
* 是否是可见的字符
*
* @param mixed $value
*
* @return boolean
*/
static function isGraph($value)
{
return ctype_graph($value);
}
示例11: insertExecute
function insertExecute()
{
$iConn = IDB::conn();
//must have DB as variable to pass to mysqli_real_escape() via iformReq()
$redirect = THIS_PAGE;
//global var used for following formReq redirection on failure
$FirstName = strip_tags(iformReq('FirstName', $iConn));
$LastName = strip_tags(iformReq('LastName', $iConn));
$Email = strip_tags(iformReq('Email', $iConn));
//next check for specific issues with data
if (!ctype_graph($_POST['FirstName']) || !ctype_graph($_POST['LastName'])) {
//data must be alphanumeric or punctuation only
feedback("First and Last Name must contain letters, numbers or punctuation");
myRedirect(THIS_PAGE);
}
if (!onlyEmail($_POST['Email'])) {
//data must be alphanumeric or punctuation only
feedback("Data entered for email is not valid");
myRedirect(THIS_PAGE);
}
//build string for SQL insert with replacement vars, %s for string, %d for digits
$sql = "INSERT INTO test_Customers (FirstName, LastName, Email) VALUES ('%s','%s','%s')";
# sprintf() allows us to filter (parameterize) form data
$sql = sprintf($sql, $FirstName, $LastName, $Email);
@mysqli_query($iConn, $sql) or die(trigger_error(mysqli_error($iConn), E_USER_ERROR));
#feedback success or failure of update
if (mysqli_affected_rows($iConn) > 0) {
//success! provide feedback, chance to change another!
feedback("Customer Added Successfully!", "notice");
} else {
//Problem! Provide feedback!
feedback("Customer NOT added!");
}
myRedirect(THIS_PAGE);
}
示例12: validateInput
/**
* Input validation driver/controller.
*/
protected function validateInput(&$input, $kind, $type, $min, $max, $pattern, $noEmptyString = true, $specificValue = false, array $rangeOfValues = NULL, &$errorMessage = NULL)
{
$tempVar = NULL;
$length = mb_strlen($input);
if ($this->equal($type, 'string') && is_string($input)) {
$tempVar = $input;
$this->stringTest($input, $kind, $length, $min, $max, $pattern, $errorMessage);
} elseif ($this->equal($type, 'int') && ctype_graph($input) && ctype_digit($input) && is_int((int) $input)) {
$tempVar = (int) $input;
//Cast string to integer datatype
$this->integerTest($input, $tempVar, $min, $max, $pattern, $errorMessage);
} elseif ($this->equal($type, 'float') && ctype_graph($input) && is_numeric($input) && is_float((double) $input)) {
$tempVar = (double) $input;
$this->floatTest($input, $tempVar, $min, $max, $pattern, $errorMessage);
} else {
$errorMessage = 'Invalid data entered!';
}
//A null error message indicates that all previous tests have passed.
if ($this->equal($errorMessage, '') && $this->matchingTest($tempVar, $noEmptyString, $specificValue, $rangeOfValues, $errorMessage)) {
return true;
}
return false;
}
示例13: ctype_graph
<?php
/* Prototype : bool ctype_graph(mixed $c)
* Description: Checks for any printable character(s) except space
* Source code: ext/ctype/ctype.c
*/
/*
* Pass strings containing different character types to ctype_graph() to test
* which are considered valid printable character only strings
*/
echo "*** Testing ctype_graph() : usage variations ***\n";
$orig = setlocale(LC_CTYPE, "C");
$values = array("This string contains just letters and spaces", "but this one contains some numbers too 123+456 = 678", "", " ", "a", "ABCXYZ", "abcxyz", "ABCXYZ123DEF456", "abczyz123DEF456", "\r\n", "123", "03F", ")speci@! ch@r\$(", '@!$*', 'ABC', 'abc', 'ABC123', 'abc123', "abc123\n", 'abc 123', '', ' ', base64_decode("w4DDoMOHw6fDiMOo"), "!\$%^&*()_+-={}[]:;@~'#<,>.?/", "\"ABC\"", "String\twith\ttabs", "Sample string with newline\n", "123 ABC XYZ");
$iterator = 1;
foreach ($values as $value) {
echo "\n-- Iteration {$iterator} --\n";
var_dump(ctype_graph($value));
$iterator++;
}
setlocale(LC_CTYPE, $orig);
?>
===DONE===
示例14: validate
public function validate($data) : bool
{
return ctype_graph($data);
}
示例15: ctype_graph
<?php
/* Prototype : bool ctype_graph(mixed $c)
* Description: Checks for any printable character(s) except space
* Source code: ext/ctype/ctype.c
*/
/*
* Pass different integers to ctype_graph() to test which character codes are considered
* valid visibly printable characters
*/
echo "*** Testing ctype_graph() : usage variations ***\n";
$orig = setlocale(LC_CTYPE, "C");
for ($i = 0; $i < 256; $i++) {
if (ctype_graph($i)) {
echo "character code {$i} is a printable character\n";
}
}
setlocale(LC_CTYPE, $orig);
?>
===DONE===