关于 True 的故事

在去年的时候,正是我写 PHP 代码最多的时候。当时经常(其实频率也没那么高)要写这样的代码(举个例而已):

define('BOOKCACHE',true);

我的重点在 true。写代码的时候因为记不住 true 的拼写,于是经常出现这样的错误:

define('BOOKCACHE',ture);

于是就出错了。刚才我想重演一下这个场景,居然 php 会自动转成字符串('ture'),那重演不了了。

不过,字符串和布尔值(true and false)毕竟还是不一样的。吃过几次重复保存、上传测试的苦之后,我终于记住了“真”的拼写: True

乱入:测试了一下,假如在 Javascript 中的话写成这样:

var sleep=ture;//这句是错的
var sleep=true;//这句是对的

就会报错:ture is not defined(当成变量去解析了)。

昨天英语考试,今天老师在校对答案的时候特意把“true”写得大大的。我很庆幸,这道题没写错,可是其他的题目——一塌糊涂。

今天写的东西有点生硬,没办法,貌似生病了。还是先写其他的吧,又失望了。

“关于 True 的故事”的9个回复

  1. 你个笨蛋、
    PHP 里 define('ture', true); 一下、
    JS 里 var ture = true; 一下、

    不就解决你的笨蛋问题了、?

    1. 嗯,也是,我好笨。现在才突然想起的。

    1. 我肯定对同龄人比较关注啦。

      比如,某人QQ空间里,根本就是我一个人在回复。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)