Php Date 无法在服务器上运行
由于某种原因,Php 日期无法在服务器上运行。
这是显示当天提示的函数。我正在使用 codeigniter 框架。在下面的函数中,我尝试打印一年中的某一天($doy)。当我转到该网址并尝试访问提示功能时,它显示一个空白页面。不打印一年中的哪一天。
public function tip(){
$idCount = $this->db->query('SELECT Count(*) AS COUNT FROM clickmag_tip')->result();
$total = $idCount[0]->COUNT;
$time = time();
$doy = mdate('%z', $time);
echo $doy;
//$day_of_year = date('z',time());
//$doyear = date("z") + 1;
//echo $doyear;
$s = mktime(date("G") + 1);
print date("Y/m/d h:i:s a", $s);
if($total > 0){
$offset = $doy % $total ;
}
$data = $this->db->query('SELECT * FROM table_tip LIMIT 1 OFFSET '. $offset);
header('Content-type: text/json');
header('Content-type: application/json');
echo json_encode($data->result());
}
您认为问题出在哪里?我和服务员谈过,但他们也不知道。 我该如何解决这个问题?
提前致谢!
for some reason the Php date isn't working on the server.
Here is the function for displaying the tip of the day. I am using the codeigniter framework. In the function below i am trying to print the day of year ($doy). When i go to the url and try to access the tip function it shows a blank page. The day of year is not printed.
public function tip(){
$idCount = $this->db->query('SELECT Count(*) AS COUNT FROM clickmag_tip')->result();
$total = $idCount[0]->COUNT;
$time = time();
$doy = mdate('%z', $time);
echo $doy;
//$day_of_year = date('z',time());
//$doyear = date("z") + 1;
//echo $doyear;
$s = mktime(date("G") + 1);
print date("Y/m/d h:i:s a", $s);
if($total > 0){
$offset = $doy % $total ;
}
$data = $this->db->query('SELECT * FROM table_tip LIMIT 1 OFFSET '. $offset);
header('Content-type: text/json');
header('Content-type: application/json');
echo json_encode($data->result());
}
What do you think is the problem? I talked to the server people but they also don't know.
How can i solve this?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在输出任何内容之前,您必须输出所有标头。
您同时拥有:
echo $doy;
和
print date("Y/m/dh:i:s a", $s);
在此之前,
这就是导致空白页的原因。
You must output all headers before outputting anything.
You have both:
echo $doy;
AND
print date("Y/m/d h:i:s a", $s);
Before
That is what's causing the blank page.