本文整理汇总了PHP中HTTP::Date方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP::Date方法的具体用法?PHP HTTP::Date怎么用?PHP HTTP::Date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTP
的用法示例。
在下文中一共展示了HTTP::Date方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: http_date_string
function http_date_string()
{
$result = FALSE;
if (class_exists('HTTP')) {
$result = HTTP::Date(time());
}
return $result;
}
示例2: getHeadersAsString
public function getHeadersAsString()
{
$text = sprintf("HTTP/%s %s %s" . self::CRLF, $this->version, $this->code, self::resolveStatusCode($this->code));
$this->setHeader(self::DATE, HTTP::Date(time()));
if ($this->body && !$this->existsHeader('Content-Type')) {
$this->setContentType('text/html;charset=UTF-8');
}
$text .= parent::getHeadersAsString() . self::CRLF;
return $text;
}
示例3: toString
public function toString()
{
$out = $this->name . '=' . urldecode($this->value);
if ($this->expire !== null) {
$out .= '; expires=' . HTTP::Date($this->expire);
}
if ($this->path !== null) {
$out .= '; path=' . $this->path;
}
if ($this->domain !== null) {
$out .= '; domain=' . urlencode($this->domain);
}
if ($this->secure === true) {
$out .= '; secure';
}
return $out;
}
示例4: setHeader
/**
* Set Header
*
* The default value for the Last-Modified header will be current
* date and atime if $value is omitted.
*
* @access public
* @return bool Returns true on success or false if $key was empty or
* $value was not of an scalar type.
* @param string $key The name of the header.
* @param string $value The value of the header. (NULL to unset header)
*/
function setHeader($key, $value = null)
{
if (empty($key) || isset($value) && !is_scalar($value)) {
return false;
}
$key = strToLower($key);
if ($key == 'last-modified') {
if (!isset($value)) {
$value = HTTP::Date(time());
} elseif (is_numeric($value)) {
$value = HTTP::Date($value);
}
}
if (isset($value)) {
$this->_headers[$key] = $value;
} else {
unset($this->_headers[$key]);
}
return true;
}
示例5: testpost
function testpost()
{
require_once 'HTTP/Request.php';
$r =& new HTTP_Request($this->testScript);
$r->setMethod(HTTP_REQUEST_METHOD_GET);
$r->sendRequest();
$lm = $r->getResponseHeader('last-modified');
$r->setMethod(HTTP_REQUEST_METHOD_POST);
$r->sendRequest();
$this->assertEquals(200, $r->getResponseCode(), 'HTTP 200 Ok (POST without If-Modified-Since)');
$r->addHeader('If-Modified-Since', HTTP::Date(strtotime('yesterday')));
$r->sendRequest();
$this->assertEquals(200, $r->getResponseCode(), 'HTTP 200 Ok (POST with If-Modified-Since == yesterday)');
$r->addHeader('If-Modified-Since', HTTP::Date(time() - 3));
$r->sendRequest();
$this->assertEquals(200, $r->getResponseCode(), 'HTTP 200 Ok (POST with If-Modified-Since == now)');
$r->addHeader('If-Modified-Since', HTTP::Date($lm));
sleep(3);
$r->sendRequest();
$this->assertEquals(200, $r->getResponseCode(), 'HTTP 200 Ok (POST with If-Modified-Since == Last-Modified)');
$this->assertEquals(HTTP::Date(), $r->getResponseHeader('last-modified'), 'POST time() == Last-Modified');
unset($r);
}
示例6: setLastModified
/**
* Set "Last-Modified"
*
* This is usually determined by filemtime() in HTTP_Download::setFile()
* If you set raw data for download with HTTP_Download::setData() and you
* want do send an appropiate "Last-Modified" header, you should call this
* method.
*
* @access public
* @return void
* @param int unix timestamp
*/
function setLastModified($last_modified)
{
$this->lastModified = HTTP::Date((int) $last_modified);
$this->headers['Last-Modified'] = (int) $last_modified;
}
示例7: testdateToTimestamp
function testdateToTimestamp()
{
$h =& new HTTP_Header();
$this->assertEquals(strtotime($d = HTTP::Date()), $h->dateToTimestamp($d));
unset($h);
}