本文整理匯總了PHP中Tool::isInt方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tool::isInt方法的具體用法?PHP Tool::isInt怎麽用?PHP Tool::isInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Tool
的用法示例。
在下文中一共展示了Tool::isInt方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getDateTime
function getDateTime($time, $zone = null)
{
if (is_a($time, 'DateTime')) {
return $time;
}
$zone = $this->getZone($zone);
if (Tool::isInt($time)) {
$Date = new DateTime(null, $zone);
$Date->setTimestamp($time);
return $Date;
}
return new DateTime($time, $zone);
}
示例2: redirect
/**
@param location location to relocate to
@param type type of relocation; head for header relocation, js for javascript relocation
*/
static function redirect($location = null, $type = 'head', $code = null)
{
if ($type == 'head') {
if (!$location) {
$location = $_SERVER['REQUEST_URI'];
}
$code = $code ? $code : 302;
header('Location: ' . $location, true, $code);
} elseif ($type == 'js') {
echo '<script type="text/javascript">';
if (Tool::isInt($location)) {
if ($location == 0) {
$location = $_SERVER['REQUEST_URI'];
echo 'window.location = ' . $_SERVER['REQUEST_URI'] . ';';
} else {
echo 'javascript:history.go(' . $location . ');';
}
} else {
echo 'document.location="' . $location . '";';
}
echo '</script>';
}
exit;
}
示例3: at
static function at($array, $index)
{
if (Tool::isInt($index) && $index < 0) {
$array = array_slice($array, $index, 1);
return $array[0];
}
return $array[$index];
}
示例4: namedId
/**
@param dict dictionary to update on query
*/
protected function namedId($table, $name, &$dict = null)
{
if (Tool::isInt($name)) {
return $name;
}
$id = $this->row($table, ['name' => $name], 'id');
if ($dict !== null) {
$dict[$name] = $id;
}
return $id;
}
示例5: age
static function age($value, $min = null, $max = null)
{
$time = new Time($value);
$age = $time->diff(new Time('now'));
if (Tool::isInt($max) && $age->y > $max) {
Debug::toss(sprintf(self::$errorMessages['age.max'], $max), 'InputException');
}
if (Tool::isInt($min) && $age->y < $min) {
Debug::toss(sprintf(self::$errorMessages['age.min'], $min), 'InputException');
}
}
示例6: send
/**
see callStatic for special static handling
@param to to address "bob <bob@bobery.com>, joe_man@susan.com"
@param subject subject of email
@param from from email address
@options array of options including bcc, cc.
*/
private function send($to, $subject, $from = null, $options = null)
{
if ($this->html) {
$this->html = self::applyLineLengthMax(utf8_encode($this->html));
}
if ($this->text) {
$this->text = self::applyLineLengthMax(utf8_encode($this->text));
}
if ($this->attached) {
$boundary = $_ENV['emailUniqueId'] . '-A-' . microtime(true);
$this->header['Content-Type'] = 'multipart/mixed; boundary="' . $boundary . '"';
$boundary = "\n\n--" . $boundary . "\n";
if ($this->html && $this->text) {
$message .= $boundary;
$alterBoundary = $_ENV['emailUniqueId'] . '-B-' . microtime(true);
$message .= 'Content-Type: multipart/alternative; boundary="' . $alterBoundary . '"';
$alterBoundary = "\n\n--" . $alterBoundary . "\n";
$message .= $alterBoundary . 'Content-type: text/plain; charset="UTF-8"' . "\n" . 'Content-Transfer-Encoding: 8bit' . "\n\n" . $this->text;
$message .= $alterBoundary . 'Content-Type: text/html; charset="UTF-8"' . "\n" . 'Content-Transfer-Encoding: 8bit' . "\n\n" . $this->html;
} elseif ($this->text) {
$message .= $boundary . 'Content-type: text/plain; charset="UTF-8"' . "\n" . 'Content-Transfer-Encoding: 8bit' . "\n\n" . $this->text;
} elseif ($this->html) {
$message .= $boundary . 'Content-type: text/plain; charset="UTF-8"' . "\n" . 'Content-Transfer-Encoding: 8bit' . "\n\n" . $this->html;
}
foreach ($this->attached as $k => $v) {
if (is_file($v)) {
$data = chunk_split(base64_encode(file_get_contents($v)));
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $v);
finfo_close($finfo);
if (!Tool::isInt($k)) {
$name = $k;
} else {
$name = basename($v);
}
$message .= $boundary . 'Content-Type: ' . $mime . '; name="' . $name . '"' . "\n" . 'Content-Transfer-Encoding: base64' . "\n" . 'Content-Disposition: attachment' . "\n\n" . $data;
}
}
} elseif ($this->html && $this->text) {
$boundary = $_ENV['emailUniqueId'] . '-A-' . microtime(true);
$this->header['Content-Type'] = 'multipart/alternative; boundary="' . $boundary . '"';
$boundary = "\n\n--" . $boundary . "\n";
$message .= $boundary . 'Content-type: text/plain; charset="UTF-8"' . "\n" . 'Content-Transfer-Encoding: 8bit' . "\n\n" . $this->text;
$message .= $boundary . 'Content-Type: text/html; charset="UTF-8"' . "\n" . 'Content-Transfer-Encoding: 8bit' . "\n\n" . $this->html;
} elseif ($this->html) {
$this->header['Content-Type'] = 'text/html; charset=UTF-8';
$message = $this->html;
} else {
$this->header['Content-Type'] = 'text/plain; charset=UTF-8';
$message = $this->text;
}
if ($from) {
$this->header['From'] = $this->header['Reply-To'] = $from;
preg_match('#[a-z0-9.\\-]+@[a-z0-9.\\-]+\\.[a-z]+#i', $from, $match);
$this->header['Return-Path'] = '<' . $match[0] . '>';
$params .= '-f' . $match[0];
}
if ($options) {
if ($options['cc']) {
$this->header['Cc'] = $options['cc'];
}
if ($options['bcc']) {
$this->header['Bcc'] = $options['bcc'];
}
}
$this->header['Message-Id'] = '<' . $_ENV['emailUniqueId'] . '-' . sha1(uniqid(microtime()) . rand(1, 100)) . '@' . gethostname() . '>';
foreach ($this->header as $k => $v) {
#not separating with \r\n because this seems to cause DKIM hash to fail
$headers .= $k . ': ' . $v . "\n";
}
if (is_array($to)) {
$to = implode(', ', $to);
}
mail($to, $subject, $message, $headers, $params);
return $this->header['Message-Id'];
}
示例7: getNode
protected function getNode($node)
{
if ($node && Tool::isInt($node)) {
return $this->db->row($this->table, $node, Arrays::implode(',', ['id', 'order_in', 'order_out', 'order_depth', $this->fkColumn]));
}
return (array) $node;
}