當前位置: 首頁>>代碼示例>>PHP>>正文


PHP vs函數代碼示例

本文整理匯總了PHP中vs函數的典型用法代碼示例。如果您正苦於以下問題:PHP vs函數的具體用法?PHP vs怎麽用?PHP vs使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了vs函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __set

 /**
  * @ignore
  */
 public function __set($name, $value)
 {
     // The purpose of this method is to detect references to undeclared object variables (properties) in
     // implementations of non-static methods, where the name of the undeclared variable could be resulting from
     // a typo.
     assert('false', vs(isset($this), get_defined_vars()));
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:10,代碼來源:CRootClass.php

示例2: encode

 /**
  * Encodes a data with Base64 encoding and returns the result.
  *
  * @param  data $data The data to be encoded.
  *
  * @return CUStringObject The encoded data.
  */
 public static function encode($data)
 {
     assert('is_cstring($data)', vs(isset($this), get_defined_vars()));
     $encodedData = base64_encode($data);
     assert('is_cstring($encodedData)', vs(isset($this), get_defined_vars()));
     return $encodedData;
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:14,代碼來源:CBase64.php

示例3: hashTypeToString

 protected static function hashTypeToString($hashType)
 {
     switch ($hashType) {
         case self::MD2:
             return "md2";
         case self::MD4:
             return "md4";
         case self::MD5:
             return "md5";
         case self::SHA1:
             return "sha1";
         case self::SHA224:
             return "sha224";
         case self::SHA256:
             return "sha256";
         case self::SHA384:
             return "sha384";
         case self::SHA512:
             return "sha512";
         case self::RIPEMD128:
             return "ripemd128";
         case self::RIPEMD160:
             return "ripemd160";
         case self::RIPEMD256:
             return "ripemd256";
         case self::RIPEMD320:
             return "ripemd320";
         case self::WHIRLPOOL:
             return "whirlpool";
         case self::TIGER128_3:
             return "tiger128,3";
         case self::TIGER160_3:
             return "tiger160,3";
         case self::TIGER192_3:
             return "tiger192,3";
         case self::TIGER128_4:
             return "tiger128,4";
         case self::TIGER160_4:
             return "tiger160,4";
         case self::TIGER192_4:
             return "tiger192,4";
         case self::SNEFRU:
             return "snefru";
         case self::SNEFRU256:
             return "snefru256";
         case self::GOST:
             return "gost";
         case self::ADLER32:
             return "adler32";
         case self::CRC32:
             return "crc32";
         case self::CRC32B:
             return "crc32b";
         case self::FNV132:
             return "fnv132";
         case self::FNV164:
             return "fnv164";
         case self::JOAAT:
             return "joaat";
         case self::HAVAL128_3:
             return "haval128,3";
         case self::HAVAL160_3:
             return "haval160,3";
         case self::HAVAL192_3:
             return "haval192,3";
         case self::HAVAL224_3:
             return "haval224,3";
         case self::HAVAL256_3:
             return "haval256,3";
         case self::HAVAL128_4:
             return "haval128,4";
         case self::HAVAL160_4:
             return "haval160,4";
         case self::HAVAL192_4:
             return "haval192,4";
         case self::HAVAL224_4:
             return "haval224,4";
         case self::HAVAL256_4:
             return "haval256,4";
         case self::HAVAL128_5:
             return "haval128,5";
         case self::HAVAL160_5:
             return "haval160,5";
         case self::HAVAL192_5:
             return "haval192,5";
         case self::HAVAL224_5:
             return "haval224,5";
         case self::HAVAL256_5:
             return "haval256,5";
         default:
             assert('false', vs(isset($this), get_defined_vars()));
     }
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:93,代碼來源:CHash.php

示例4: enterTd

 /**
  * In a string, escapes all characters that have a special meaning in the regular expression domain, and returns
  * the escaped string.
  *
  * With this method, you can prepare an arbitrary string to be used as a part of a regular expression.
  *
  * @param  string $string The string to be escaped.
  * @param  string $delimiter **OPTIONAL. Default is** "/". The pattern delimiter that is going to be used by the
  * resulting regular expression and therefore needs to be escaped as well.
  *
  * @return string The escaped string.
  */
 public static function enterTd($string, $delimiter = self::DEFAULT_PATTERN_DELIMITER)
 {
     assert('is_cstring($string) && is_cstring($delimiter)', vs(isset($this), get_defined_vars()));
     return preg_quote($string, $delimiter);
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:17,代碼來源:CRegex.php

示例5: isNameIcuCompatible

 /**
  * @ignore
  */
 public static function isNameIcuCompatible($name)
 {
     assert('is_cstring($name)', vs(isset($this), get_defined_vars()));
     $itz = IntlTimeZone::createTimeZone($name);
     return CString::equals($name, $itz->getID());
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:9,代碼來源:CTimeZone.php

示例6: finalize

 protected function finalize()
 {
     $res = fclose($this->m_file);
     assert('$res', vs(isset($this), get_defined_vars()));
     $this->m_done = true;
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:6,代碼來源:CFile.php

示例7: setMailing

 public static function setMailing(CMail $mail, $minTimeBetweenSendMailHours = self::DEFAULT_MIN_TIME_BETWEEN_SEND_MAIL_HOURS)
 {
     // Enables mailing about encountered errors with the provided CMail object.
     assert('is_int($minTimeBetweenSendMailHours)', vs(isset($this), get_defined_vars()));
     assert('$minTimeBetweenSendMailHours >= 0', vs(isset($this), get_defined_vars()));
     self::$ms_mailing = true;
     self::$ms_mail = $mail;
     self::$ms_minTimeBetweenSendMailHours = $minTimeBetweenSendMailHours;
     self::registerHandlers();
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:10,代碼來源:CDebug.php

示例8: leaveTdAll

 /**
  * Translates a string out of the XML text domain, replacing all XML entities with their literal equivalents.
  *
  * Both double and single quotes are translated.
  *
  * @param  string $string The string to be translated.
  *
  * @return CUStringObject The translated string.
  */
 public static function leaveTdAll($string)
 {
     assert('is_cstring($string)', vs(isset($this), get_defined_vars()));
     return html_entity_decode($string, ENT_QUOTES, "UTF-8");
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:14,代碼來源:CXml.php

示例9: convertMassf

 /**
  * Converts a floating-point quantity of mass from one unit into another and returns the result.
  *
  * @param  float $quantity The quantity to be converted.
  * @param  enum $fromUnit The source unit.
  * @param  enum $toUnit The destination unit.
  *
  * @return float The converted quantity.
  */
 public static function convertMassf($quantity, $fromUnit, $toUnit)
 {
     assert('is_float($quantity) && is_enum($fromUnit) && is_enum($toUnit)', vs(isset($this), get_defined_vars()));
     assert('$quantity >= 0.0', vs(isset($this), get_defined_vars()));
     if ($fromUnit == $toUnit) {
         return $quantity;
     }
     $milligramQty;
     switch ($fromUnit) {
         case self::MILLIGRAM:
             $milligramQty = $quantity;
             break;
         case self::GRAM:
             $milligramQty = $quantity * 1000;
             break;
         case self::KILOGRAM:
             $milligramQty = $quantity * 1000000;
             break;
         case self::TON:
             $milligramQty = $quantity * 1000000000;
             break;
         case self::OUNCE:
             $milligramQty = $quantity * 28349.5231;
             break;
         case self::POUND:
             $milligramQty = $quantity * 453592.37;
             break;
         case self::STONE:
             $milligramQty = $quantity * 6350293.18;
             break;
         case self::SHORT_TON:
             $milligramQty = $quantity * 907184740;
             break;
         case self::LONG_TON:
             $milligramQty = $quantity * 1016046908.8;
             break;
         default:
             assert('false', vs(isset($this), get_defined_vars()));
             break;
     }
     $outputQty;
     switch ($toUnit) {
         case self::MILLIGRAM:
             $outputQty = $milligramQty;
             break;
         case self::GRAM:
             $outputQty = $milligramQty / 1000;
             break;
         case self::KILOGRAM:
             $outputQty = $milligramQty / 1000000;
             break;
         case self::TON:
             $outputQty = $milligramQty / 1000000000;
             break;
         case self::OUNCE:
             $outputQty = $milligramQty / 28349.5231;
             break;
         case self::POUND:
             $outputQty = $milligramQty / 453592.37;
             break;
         case self::STONE:
             $outputQty = $milligramQty / 6350293.18;
             break;
         case self::SHORT_TON:
             $outputQty = $milligramQty / 907184740;
             break;
         case self::LONG_TON:
             $outputQty = $milligramQty / 1016046908.8;
             break;
         default:
             assert('false', vs(isset($this), get_defined_vars()));
             break;
     }
     return $outputQty;
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:84,代碼來源:CUUnit.php

示例10: frameworkPath

 /**
  * Replaces any reference to one of the framework's special directories in a path with the directory's actual path
  * and returns the usable path.
  *
  * A framework's directory is referenced in a path by wrapping its ID into double curly braces, as in
  * "{{PHRED_PATH_TO_FRAMEWORK_ROOT}}", optionally with "/" after the reference.
  *
  * @param  string $path The path to the file or directory (can be absolute or relative).
  *
  * @return CUStringObject The usable path.
  */
 public static function frameworkPath($path)
 {
     assert('!isset($path) || is_cstring($path)', vs(isset($this), get_defined_vars()));
     if (!isset($path)) {
         return null;
     }
     // Replace every "{{EXAMPLE_PATH}}" in the path string with the value of "EXAMPLE_PATH" key from $GLOBALS
     // variable if such key exists in the variable.
     $modified = false;
     $path = CRegex::replaceWithCallback($path, "/\\{\\{\\w+\\}\\}/", function ($matches) use(&$modified) {
         $pathVarName = CString::substr($matches[0], 2, CString::length($matches[0]) - 4);
         if (isset($GLOBALS[$pathVarName])) {
             $modified = true;
             return $GLOBALS[$pathVarName] . "/";
         } else {
             assert('false', vs(isset($this), get_defined_vars()));
             return $matches[0];
         }
     });
     if ($modified) {
         $path = CRegex::replace($path, "/\\/{2,}/", "/");
     }
     return $path;
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:35,代碼來源:CFilePath.php

示例11: repeat

 /**
  * Repeats an element for a specified number of times and returns the resulting array.
  *
  * For instance, an element of "a" repeated three times would result in an array of "a", "a", "a".
  *
  * @param  mixed $element The element to be repeated.
  * @param  int $times The length of the resulting array.
  *
  * @return CArray The resulting array.
  */
 public static function repeat($element, $times)
 {
     assert('is_int($times)', vs(isset($this), get_defined_vars()));
     assert('$times > 0', vs(isset($this), get_defined_vars()));
     $resArray = self::make($times);
     for ($i = 0; $i < $times; $i++) {
         $resArray[$i] = $element;
     }
     return $resArray;
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:20,代碼來源:CArray.php

示例12: repeat

 /**
  * Repeats a string for a specified number of times and returns the resulting string.
  *
  * For instance, the string of "a" repeated three times would result in "aaa".
  *
  * @param  string $string The string to be repeated.
  * @param  int $times The number of times for the string to be repeated.
  *
  * @return string The resulting string.
  */
 public static function repeat($string, $times)
 {
     assert('is_cstring($string) && is_int($times)', vs(isset($this), get_defined_vars()));
     assert('$times > 0 || (self::isEmpty($string) && $times == 0)', vs(isset($this), get_defined_vars()));
     return str_repeat($string, $times);
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:16,代碼來源:CString.php

示例13: patternEnumToString

 protected static function patternEnumToString($pattern)
 {
     switch ($pattern) {
         case self::PATTERN_DEFAULT:
             return "Y-m-d H:i:s e";
         case self::PATTERN_DEFAULT_DATE:
             return "Y-m-d";
         case self::PATTERN_DEFAULT_TIME:
             return "H:i:s";
         case self::PATTERN_ATOM:
             return "Y-m-d\\TH:i:sP";
         case self::PATTERN_COOKIE:
             return "l, d-M-y H:i:s T";
         case self::PATTERN_HTTP_HEADER_GMT:
             return "D, d M Y H:i:s T";
         case self::PATTERN_ISO8601:
             return "Y-m-d\\TH:i:sO";
         case self::PATTERN_MYSQL:
             return "Y-m-d H:i:s";
         case self::PATTERN_RFC822:
             return "D, d M y H:i:s O";
         case self::PATTERN_RFC850:
             return "l, d-M-y H:i:s T";
         case self::PATTERN_RFC1036:
             return "D, d M y H:i:s O";
         case self::PATTERN_RFC2822:
             return "D, d M Y H:i:s O";
         case self::PATTERN_RFC3339:
             return "Y-m-d\\TH:i:sP";
         case self::PATTERN_RSS:
             return "D, d M Y H:i:s O";
         case self::PATTERN_W3C:
             return "Y-m-d\\TH:i:sP";
         default:
             assert('false', vs(isset($this), get_defined_vars()));
     }
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:37,代碼來源:CTime.php

示例14: onThirdPartyUpdateByPackageManager

 /**
  * @ignore
  */
 public static function onThirdPartyUpdateByPackageManager()
 {
     if (!self::isInCliMode()) {
         // This method can be run in CLI mode only.
         assert('false', vs(isset($this), get_defined_vars()));
     }
     $timeoutPause = new CTimeoutPause();
     CShell::speak("Processing third-party components ...");
     $tpDps = CFile::listDirectories(CFilePath::absolute($GLOBALS["PHRED_PATH_TO_THIRD_PARTY"]));
     $ignorePackages = CConfiguration::option("upd.thirdPartyOopWrappingIgnorePackages");
     $ignorePackagesL2 = CArray::filter($ignorePackages, function ($package) {
         return CString::find($package, "/");
     });
     $newTpDps = CArray::make();
     $len = CArray::length($tpDps);
     for ($i = 0; $i < $len; $i++) {
         $tpDp = $tpDps[$i];
         $dirName = CFilePath::name($tpDp);
         if (!CArray::find($ignorePackages, $dirName)) {
             $dpHasL2DirsToIgnore = CArray::find($ignorePackagesL2, $dirName, function ($packageL2, $dirName) {
                 return CString::equals(CFilePath::directory($packageL2), $dirName);
             });
             if (!$dpHasL2DirsToIgnore) {
                 CArray::push($newTpDps, $tpDp);
             } else {
                 $tpSubDps = CFile::listDirectories($tpDp);
                 $tpSubDps = CArray::filter($tpSubDps, function ($subDp) use($ignorePackagesL2) {
                     return !CArray::find($ignorePackagesL2, $subDp, function ($packageL2, $subDp) {
                         return CString::endsWith($subDp, $packageL2);
                     });
                 });
                 CArray::pushArray($newTpDps, $tpSubDps);
             }
         }
     }
     $tpDps = $newTpDps;
     $wrapProtectedMethods = CConfiguration::option("upd.thirdPartyOopWrappingInProtectedMethods");
     $wrapPrivateMethods = CConfiguration::option("upd.thirdPartyOopWrappingInPrivateMethods");
     static $s_stdPhpTag = "<?php";
     static $s_progressResolution = 0.05;
     $prevProgressDivR = 0;
     $tpDpsLen = CArray::length($tpDps);
     for ($i0 = 0; $i0 < $tpDpsLen; $i0++) {
         $tpFps = CFile::reFindFilesRecursive($tpDps[$i0], "/\\.php\\d?\\z/");
         $tpFpsLen = CArray::length($tpFps);
         for ($i1 = 0; $i1 < $tpFpsLen; $i1++) {
             $fileCode = CFile::read($tpFps[$i1]);
             if (!CString::find($fileCode, self::$ms_thirdPartyAlreadyOopWrappedMark)) {
                 $parser = new PhpParser\Parser(new PhpParser\Lexer());
                 try {
                     // Parse the code.
                     $statements = $parser->parse($fileCode);
                     // Wrap the code into OOP.
                     $traverser = new PhpParser\NodeTraverser();
                     $mainVisitor = new CMainVisitor($wrapProtectedMethods, $wrapPrivateMethods);
                     $traverser->addVisitor($mainVisitor);
                     $statements = $traverser->traverse($statements);
                     $wrappedCode = (new PhpParser\PrettyPrinter\Standard())->prettyPrint($statements);
                     $phpTagPos = CString::indexOf($wrappedCode, $s_stdPhpTag);
                     if ($phpTagPos == -1) {
                         $wrappedCode = "{$s_stdPhpTag}\n\n{$wrappedCode}";
                         $phpTagPos = 0;
                     }
                     $wrappedCode = CString::insert($wrappedCode, $phpTagPos + CString::length($s_stdPhpTag), "\n\n" . self::$ms_thirdPartyAlreadyOopWrappedMark);
                     // Save.
                     CFile::write($tpFps[$i1], $wrappedCode);
                 } catch (PhpParser\Error $parserError) {
                     CShell::say("\nPhpParser: " . $tpFps[$i1] . ", at line " . $parserError->getRawLine() . ": " . $parserError->getRawMessage());
                 }
             }
             $progress = (double) ($i0 / $tpDpsLen + 1 / $tpDpsLen * $i1 / $tpFpsLen);
             $progressDivR = CMathi::floor($progress / $s_progressResolution);
             if ($progressDivR != $prevProgressDivR) {
                 $perc = CMathi::round($progressDivR * $s_progressResolution * 100);
                 CShell::speak("{$perc}%");
             }
             $prevProgressDivR = $progressDivR;
         }
     }
     CShell::speak("100%");
     CShell::say("Done.");
     $timeoutPause->end();
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:86,代碼來源:CSystem.php

示例15: leaveTdOld

 /**
  * In a string, removes percent-encoding (URL encoding) from all characters encoded according to the older flavor
  * of percent-encoding and returns the new string.
  *
  * According to the older flavor of percent-encoding, the space character is decoded from either "+" or "%20"
  * (literal spaces are not permitted in a valid URL), "+" from "%2B" only, and "~" from either "%7E" or "~". This
  * flavor of percent-encoding is primarily used with query strings in URLs and with
  * "application/x-www-form-urlencoded" data in POST requests. In any other place, the newer flavor of
  * percent-encoding is usually preferred.
  *
  * @param  string $string The string to be translated out of the URL text domain.
  *
  * @return CUStringObject The translated string.
  */
 public static function leaveTdOld($string)
 {
     assert('is_cstring($string)', vs(isset($this), get_defined_vars()));
     return urldecode($string);
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:19,代碼來源:CUrl.php


注:本文中的vs函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。