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


PHP CString::padStart方法代碼示例

本文整理匯總了PHP中CString::padStart方法的典型用法代碼示例。如果您正苦於以下問題:PHP CString::padStart方法的具體用法?PHP CString::padStart怎麽用?PHP CString::padStart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CString的用法示例。


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

示例1: componentsInTimeZoneToTime

 protected static function componentsInTimeZoneToTime($year, $month, $day, $hour, $minute, $second, $millisecond, $timeZone)
 {
     assert('self::areComponentsValid($year, $month, $day, $hour, $minute, $second, $millisecond)', vs(isset($this), get_defined_vars()));
     assert('1000 <= $year && $year <= 9999', vs(isset($this), get_defined_vars()));
     $strYear = CString::fromInt($year);
     $strMonth = CString::fromInt($month);
     $strDay = CString::fromInt($day);
     $strHour = CString::padStart(CString::fromInt($hour), "0", 2);
     $strMinute = CString::padStart(CString::fromInt($minute), "0", 2);
     $strSecond = CString::padStart(CString::fromInt($second), "0", 2);
     $dt = DateTime::createFromFormat("Y,m,d,H,i,s", "{$strYear},{$strMonth},{$strDay},{$strHour},{$strMinute},{$strSecond}", is_cstring($timeZone) ? new DateTimeZone($timeZone) : $timeZone->DTimeZone());
     if (!is_object($dt)) {
         assert('false', vs(isset($this), get_defined_vars()));
     }
     $UTime = $dt->getTimestamp();
     $MTime;
     if (!($UTime < 0 && $millisecond != 0)) {
         $MTime = $millisecond;
     } else {
         $UTime++;
         $MTime = $millisecond - 1000;
     }
     return new self($UTime, $MTime);
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:24,代碼來源:CTime.php

示例2: fromCharCodeEsc

 /**
  * Returns a character by its code point specified in an escaped fashion.
  *
  * For instance, "\u0041" would return "A".
  *
  * @param  string $code The Unicode code point prefixed with "\u". The number of hexadecimal digits in the string
  * should be four.
  *
  * @return string The Unicode character with the code point specified.
  */
 public static function fromCharCodeEsc($code)
 {
     assert('is_cstring($code)', vs(isset($this), get_defined_vars()));
     assert('CRegex::find($code, "/^\\\\\\\\u((?i)[0-9A-F]{4}(?<!FFFE|FFFF))\\\\z/")', vs(isset($this), get_defined_vars()));
     return json_decode("\"\\u" . CString::padStart(CString::substr($code, 2), "0", 4) . "\"");
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:16,代碼來源:CUString.php


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