当前位置: 首页>>代码示例>>PHP>>正文


PHP ctype_graph函数代码示例

本文整理汇总了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);
 }
开发者ID:romeoz,项目名称:rock-validate,代码行数:11,代码来源:Graph.php

示例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;
 }
开发者ID:ThisNameWasFree,项目名称:rude-univ,代码行数:67,代码来源:rude-stream.php

示例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===
开发者ID:badlamer,项目名称:hhvm,代码行数:30,代码来源:ctype_graph_variation4.php

示例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.'));
开发者ID:extend,项目名称:wee,代码行数:29,代码来源:ctype_graph.php

示例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);
 }
开发者ID:xuelunlu,项目名称:BKManagement,代码行数:20,代码来源:Yubikey.php

示例6: hasGraphicalCharsOnly

 /**
  * @param string $value
  *
  * @return bool
  */
 public static function hasGraphicalCharsOnly($value)
 {
     return \ctype_graph($value);
 }
开发者ID:nilportugues,项目名称:php-validator,代码行数:9,代码来源:StringValidation.php

示例7: isSingleline

 public static function isSingleline($data, $options = array())
 {
     return ctype_graph($data);
 }
开发者ID:BackupTheBerlios,项目名称:stato-svn,代码行数:4,代码来源:validation.php

示例8: _passwordHash

 private function _passwordHash(&$data, $value)
 {
     $data['passwordHash'] = ctype_graph($value) && strlen($value) >= 60 ? $value : '';
 }
开发者ID:krisfremen,项目名称:FreshRSS,代码行数:4,代码来源:ConfigurationSetter.php

示例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);
 }
开发者ID:bdusell,项目名称:jitsu-string,代码行数:12,代码来源:StringUtil.php

示例10: isGraph

 /**
  * 是否是可见的字符
  *
  * @param mixed $value
  *
  * @return boolean
  */
 static function isGraph($value)
 {
     return ctype_graph($value);
 }
开发者ID:naffan2014,项目名称:PHPcommonTool,代码行数:11,代码来源:Validator.php

示例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);
}
开发者ID:bschwartz757,项目名称:PHP-MySQL,代码行数:35,代码来源:L4-1.php

示例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;
 }
开发者ID:TimeFliesWebDesign,项目名称:ASCI_OPP_PHP_Code_Sample,代码行数:26,代码来源:index.php

示例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===
开发者ID:badlamer,项目名称:hhvm,代码行数:22,代码来源:ctype_graph_variation3.php

示例14: validate

 public function validate($data) : bool
 {
     return ctype_graph($data);
 }
开发者ID:z7zmey,项目名称:rvalidate,代码行数:4,代码来源:Graph.php

示例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===
开发者ID:badlamer,项目名称:hhvm,代码行数:20,代码来源:ctype_graph_variation2.php


注:本文中的ctype_graph函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。