本文整理汇总了PHP中CString::fromInt方法的典型用法代码示例。如果您正苦于以下问题:PHP CString::fromInt方法的具体用法?PHP CString::fromInt怎么用?PHP CString::fromInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::fromInt方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Creates an HTTP cookie to be sent along with an HTTP response.
*
* Internally, the value of a cookie is always stored as a string. If the cookie's value was provided as an array
* or map, it's encoded into JSON and is stored as a JSON string. Boolean values are stored as "1" for `true` and
* as "0" for `false`.
*
* @param string $cookieName The cookie's name.
* @param mixed $value The cookie's value. This can be a string, a `bool`, an `int`, a `float`, an array, or a
* map.
*/
public function __construct($cookieName, $value)
{
assert('is_cstring($cookieName) && (is_cstring($value) || is_bool($value) || is_int($value) || ' . 'is_float($value) || is_collection($value))', vs(isset($this), get_defined_vars()));
$this->m_name = $cookieName;
if (is_cstring($value)) {
$this->m_value = $value;
} else {
if (is_bool($value)) {
$this->m_value = CString::fromBool10($value);
} else {
if (is_int($value)) {
$this->m_value = CString::fromInt($value);
} else {
if (is_float($value)) {
$this->m_value = CString::fromFloat($value);
} else {
$json = new CJson($value);
$this->m_value = $json->encode();
}
}
}
}
}
示例2: join
/**
* Joins the elements of an array into a string.
*
* The elements in the source array are not required to be all strings and, in addition to types that know how to
* become a string, an element can be `int`, `float`, or `bool`. In the resulting string, a boolean value of
* `true` becomes "1" and `false` becomes "0".
*
* As a special case, the array is allowed to be empty.
*
* @param array $array The array containing the elements to be joined.
* @param string $binder The string to be put between any two elements in the resulting string, such as ", ".
* Can be empty.
*
* @return string The resulting string.
*/
public static function join($array, $binder)
{
assert('is_carray($array) && is_cstring($binder)', vs(isset($this), get_defined_vars()));
$array = splarray($array);
$array = self::makeCopy($array);
for ($i = 0; $i < $array->getSize(); $i++) {
if (!is_cstring($array[$i])) {
if (is_bool($array[$i])) {
$array[$i] = CString::fromBool10($array[$i]);
} else {
if (is_int($array[$i])) {
$array[$i] = CString::fromInt($array[$i]);
} else {
if (is_float($array[$i])) {
$array[$i] = CString::fromFloat($array[$i]);
}
}
}
}
}
return implode($binder, self::toPArray($array));
}
示例3: shiftTimeInTimeZone
protected static function shiftTimeInTimeZone(CTime $time, $timeUnit, $quantity, $timeZone)
{
$units;
switch ($timeUnit) {
case self::SECOND:
$units = "seconds";
break;
case self::MINUTE:
$units = "minutes";
break;
case self::HOUR:
$units = "hours";
break;
case self::DAY:
$units = "days";
break;
case self::WEEK:
$units = "weeks";
break;
case self::MONTH:
$units = "months";
break;
case self::YEAR:
$units = "years";
break;
default:
assert('false', vs(isset($this), get_defined_vars()));
break;
}
$dt = new DateTime();
$dt->setTimestamp($time->UTime());
$dt->setTimezone(is_cstring($timeZone) ? new DateTimeZone($timeZone) : $timeZone->DTimeZone());
$sign = $quantity < 0 ? "-" : "+";
$absQty = CString::fromInt(CMathi::abs($quantity));
$dt->modify("{$sign}{$absQty} {$units}");
$UTime = $dt->getTimestamp();
$MTime = $time->MTime();
if ($UTime != 0 && $MTime != 0 && CMathi::sign($UTime) != CMathi::sign($MTime)) {
if ($UTime < 0) {
// $MTime > 0
$UTime++;
$MTime -= 1000;
} else {
// $MTime < 0
$UTime--;
$MTime += 1000;
}
}
return new self($UTime, $MTime);
}
示例4: maybeUpdateThirdParty
//.........这里部分代码省略.........
if (CFile::exists($lastUpdateTimeFp)) {
$lastUpdateTime = new CTime(CString::toInt(CFile::read($lastUpdateTimeFp)));
$currTime = CTime::now();
if ($lastUpdateTime->isBefore($currTime)) {
$numDaysSinceLastUpdate = $currTime->diffInDays($lastUpdateTime);
if ($numDaysSinceLastUpdate < $minTimeBetweenDoUpdatesDays) {
// It is too early for updates yet.
return false;
}
} else {
assert('false', vs(isset($this), get_defined_vars()));
}
}
$date = CShell::currentDate();
CShell::say("Started on {$date}.");
if (isset($numDaysSinceLastUpdate)) {
CShell::say("It has been {$numDaysSinceLastUpdate} day(s) since last successful update.");
}
$concurrLockFp = CFilePath::add($thirdPartyDp, self::$ms_thirdPartyConcurrLockFn);
// Try locking the operation.
if (!self::setLock($concurrLockFp, false)) {
assert('false', vs(isset($this), get_defined_vars()));
CShell::onError(false, "Could not obtain a lock on the operation.");
CShell::writeToLog("\n");
return false;
}
$phpConfigNeedsReload = false;
$totalNumComponents = CMap::length($components);
$numComponentsUpdated = 0;
// The Browser Capabilities Project (BrowsCap).
if (CMap::hasKey($components, "browsCap")) {
$browsCap = $components["browsCap"];
$skip = $browsCap["skip"];
if (!$skip) {
CShell::say("Updating the Browser Capabilities Project (BrowsCap) ...");
$lookupFileUrl = $browsCap["lookupFileUrl"];
assert('!CString::isEmpty($lookupFileUrl)', vs(isset($this), get_defined_vars()));
// Component-related constants.
static $s_configOptName = "browscap";
static $s_lookupFileDownloadTimeoutSeconds = 120;
if (self::hasConfigOption($s_configOptName)) {
$browsCapLookupFp = CString::trim(self::configOption($s_configOptName));
if (!CString::isEmpty($browsCapLookupFp)) {
$browsCapDp = CFilePath::directory($browsCapLookupFp);
CShell::say("Downloading a BrowsCap lookup file from '{$lookupFileUrl}' ...");
$temporaryFp = CFile::createTemporary($browsCapDp);
$downloadRes = CInetRequest::downloadFile($lookupFileUrl, $temporaryFp, $s_lookupFileDownloadTimeoutSeconds);
if ($downloadRes) {
// After the file is downloaded into a temporary one, move it to the destination,
// safely replacing the existing file, if any.
CFile::move($temporaryFp, $browsCapLookupFp);
$numComponentsUpdated++;
$phpConfigNeedsReload = true;
$downloadedFileSizeKB = CUUnit::convertStoragef((double) CFile::size($browsCapLookupFp), CUUnit::BYTE, CUUnit::KILOBYTE);
$downloadedFileSizeKB = CMathf::round($downloadedFileSizeKB, 2);
CShell::say("Done. The downloaded file is {$downloadedFileSizeKB} KB in size.");
} else {
CShell::onError(false, "Could not download a BrowsCap lookup file from '{$lookupFileUrl}'.");
}
// Just in case, check for any temporary files that could have been left by any previous
// operations in the directory.
$leftoverFiles = CFile::findFiles(CFilePath::add($browsCapDp, CFile::DEFAULT_TEMPORARY_FILE_PREFIX . "*"));
if (!CArray::isEmpty($leftoverFiles)) {
// Cleanup the directory from the temporary files.
$len = CArray::length($leftoverFiles);
for ($i = 0; $i < $len; $i++) {
CFile::delete($leftoverFiles[$i]);
}
}
} else {
CShell::onError(false, "Could not read the value of '{$s_configOptName}' option " . "in the PHP CLI configuration file.");
}
} else {
CShell::onError(false, "Could not find '{$s_configOptName}' option in the PHP CLI configuration file.");
}
} else {
CShell::say("Skipping the Browser Capabilities Project (BrowsCap).");
}
}
// All the components have been processed. Unlock the operation.
self::unsetLock($concurrLockFp);
$date = CShell::currentDate();
if ($numComponentsUpdated != 0) {
// One or more third-party components have been updated. Put a time stamp on the directory where the
// components are located.
CFile::write($lastUpdateTimeFp, CString::fromInt(CTime::currentUTime()));
if ($numComponentsUpdated == $totalNumComponents) {
CShell::speak("Success. All {$totalNumComponents} third-party component(s)");
} else {
CShell::speak("Partial success. {$numComponentsUpdated} out of {$totalNumComponents} third-party component(s)");
}
CShell::say("have been updated. Completed on {$date}.");
} else {
CShell::say("No third-party components have been updated. Completed on {$date}.");
}
return $phpConfigNeedsReload;
} else {
return false;
}
}
示例5: fromCharCode
/**
* Returns a character by its code point specified as an integer.
*
* @param int $code The Unicode code point.
*
* @return string The Unicode character with the code point specified.
*/
public static function fromCharCode($code)
{
assert('is_int($code)', vs(isset($this), get_defined_vars()));
assert('0 <= $code && $code < 0xFFFE', vs(isset($this), get_defined_vars()));
return json_decode("\"\\u" . CString::padStart(CString::decToHex(CString::fromInt($code)), "0", 4) . "\"");
}
示例6: requestSslVerificationResult
/**
* Returns the result of the verification of the SSL certificate of the remote server.
*
* @return bool `true` if the SSL certificate was verified successfully, `false` otherwise.
*/
public function requestSslVerificationResult()
{
assert('$this->m_done && !$this->m_hasError', vs(isset($this), get_defined_vars()));
$key = "ssl_verify_result";
if (CMap::hasKey($this->m_requestSummary, $key)) {
$value = $this->m_requestSummary[$key];
if (!is_bool($value)) {
if (!is_cstring($value)) {
$value = CString::fromInt($value);
}
return CString::toBool($value);
} else {
return $value;
}
} else {
return false;
}
}
示例7: recurseQueryValueBeforeComposingQs
protected static function recurseQueryValueBeforeComposingQs($value, $currDepth)
{
if ($currDepth == self::$ms_maxRecursionDepth) {
return $value;
}
$currDepth++;
if (!is_collection($value)) {
if (!is_cstring($value)) {
if (is_bool($value)) {
$value = CString::fromBool10($value);
} else {
if (is_int($value)) {
$value = CString::fromInt($value);
} else {
if (is_float($value)) {
$value = CString::fromFloat($value);
} else {
assert('false', vs(isset($this), get_defined_vars()));
}
}
}
}
return $value;
}
if (is_carray($value)) {
$value = splarray($value)->toArray();
} else {
$value = parray($value);
}
foreach ($value as &$mapValue) {
$mapValue = self::recurseQueryValueBeforeComposingQs($mapValue, $currDepth);
}
unset($mapValue);
return $value;
}
示例8: collectionElementToString
protected static function collectionElementToString($elementValue, &$success)
{
if (is_cstring($elementValue)) {
return $elementValue;
}
if (is_bool($elementValue)) {
return CString::fromBool10($elementValue);
}
if (is_int($elementValue)) {
return CString::fromInt($elementValue);
}
if (is_float($elementValue)) {
return CString::fromFloat($elementValue);
}
$success = false;
}