之前发帖子说正式启用eztk.net域名,见证人列表工具移至网站根目录,但是这个站点目前只有一个Witness List,所以我实在不知道主页该写点啥。
(图源 :pixabay)
既然没啥写的,就先跳转到Witness List,其实跳转的方法有好多种,比如用Apache的URL_REWRITE
或者用HTML代码<meta http-equiv="refresh" content="5;url=https://www.eztk.net/witnesses.php">
或者用JavaScripte的window.location.href='https://www.eztk.net/witnesses.php;
不过我最喜欢用的还是如下代码:
<?php
header('Location: https://www.eztk.net/witnesses.php');
?>
编辑index.php,填上上述代码,保存并上传到服务器,访问,然后美滋滋地等跳转,结果一片空白,并没有跳转至我要的页面,这是咋回事呢?
查看了一下error_log
发现了如下内容:
[30-Oct-2018 02:44:49 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/index.php:1) in /home/user/public_html/index.php on line 2
哦,原来是这个问题啊,这个问题几十年前刚学PHP的时候我遇到无数次了,不过是在header()
之前有了其它输出嘛(字符啊、空格之类的),去掉就好了。结果我瞪大眼睛找了半天,也没找到任何字符。
会是什么原因呢?我冥思苦想,想了好久终于灵光一现,我该不会手贱把PHP文件格式设置成了UTF-8 (BOM)
了吧?
点击另存为,看了一下当前的文件格式,果不其然是UTF-8 (BOM)
而UTF-8
和UTF-8 (BOM)
文件格式有啥区别呢?我们来对比一下两个文件的二进制码就知道了
经过对比我们发现,后者比前者多出来三个字节0xEF,0xBB,0xBF
,这就是导致Cannot modify header information - headers already sent by
的罪魁祸首啦。
那么解决起来也很简单了,把文件另存为UTF-8
,就搞定啦。
有关更多关于BOM的细节,去参考Byte order mark吧,我就不献丑啦。
相关链接
- Byte order mark
- Witness List by @oflyhigh
- 温故而知新:复习一下字符编码(ASCII、GB2312、Unicode、UTF-8、区位码)
- 纸上得来终觉浅:来验证一下编码的问题
- 每天进步一点点:VC中不同编码间字符串转换
https://steemit.com/~witnesses type in
oflyhigh
and click VOTE
Vote @oflyhigh via Steemconnect
Thank you!
题图用了无数次了……
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
哈哈这个叫做branding
Posted using Partiko Android
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
机智👍
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
😎
Posted using Partiko Android
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
👍
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
码农的事儿真是不懂呀
Posted using Partiko Android
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hello! Your post has been resteemed and upvoted by @ilovecoding because we love coding! Keep up good work! Consider upvoting this comment to support the @ilovecoding and increase your future rewards! ^_^ Steem On!
Reply !stop to disable the comment. Thanks!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit