测试得知:php文件记事本打开另存为ansi格式,发送或接收的中文字符串才能正常显示,否则就是乱码的。 可不可以改成utf8格式也能正常显示中文呢?
timer添加定时器:
$time_init = 300; $timerId = Timer::add(1, function($time_init){ echo "time:".$time_init.",status=0\n"; $time_init -- ; if ($time_init <= 295 && $time_init > 290){ echo "time:".$time_init.",status=1\n"; }else if ($time_init <= 290){ echo "time:".$time_init.",status=2\n"; } },array($time_init));
怎样才能做到 $time_init 每秒自减呢?现在这样打印出来 $time_init 一直是300,没变~
$time_init = 300; $timerId = Timer::add(1, function() use (&$time_init){ echo "time:".$time_init.",status=0\n"; $time_init -- ; if ($time_init <= 295 && $time_init > 290){ echo "time:".$time_init.",status=1\n"; }else if ($time_init <= 290){ echo "time:".$time_init.",status=2\n"; } }));
或者
$time_init = 300; $timerId = Timer::add(1, function(){ global $time_init; echo "time:".$time_init.",status=0\n"; $time_init -- ; if ($time_init <= 295 && $time_init > 290){ echo "time:".$time_init.",status=1\n"; }else if ($time_init <= 290){ echo "time:".$time_init.",status=2\n"; } });
$timerId = Timer::add(1, function(){ static $time_init = 300; echo "time:".$time_init.",status=0\n"; $time_init -- ; if ($time_init <= 295 && $time_init > 290){ echo "time:".$time_init.",status=1\n"; }else if ($time_init <= 290){ echo "time:".$time_init.",status=2\n"; } });
。。。
3Q,那编码问题怎么处理呢?难道只能用gbk么?
编码都建议用utf8,显示乱码是显示终端没设置好编码
timer添加定时器:
怎样才能做到 $time_init 每秒自减呢?现在这样打印出来 $time_init 一直是300,没变~
或者
或者
。。。
3Q,那编码问题怎么处理呢?难道只能用gbk么?
编码都建议用utf8,显示乱码是显示终端没设置好编码