Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use TRUE, FALSE, and NULL

I am reading a Codeigniter book, it said like this,

When using the keywords TRUE,FALSE, and NULL in your application, you should always write them in Uppercase letters.

Why does Codeigniter need all the keywords write as uppercase letters?

like image 807
Nano HE Avatar asked Apr 20 '26 01:04

Nano HE


2 Answers

CodeIgniter/PHP does not require that you write those words in uppercase letters of not.

However it is CodeIgniter's Coding Style to write them like this.

CodeIgniter has been developing following that Coding Style, so if you want your code to look like CodeIgniter's, then you should follow that as well...

Also if you want to share any of your work with the CodeIgniter community then it will be written how they would expect.

See Coding Conventions

like image 110
Jacob Avatar answered Apr 22 '26 18:04

Jacob


Sadly, CodeIgniter wrongly attributes TRUE, FALSE and NULL the status of keywords. While they may appear as such, they actually haven't been keywords since the official release of PHP3 except for an extremely brief period for PHP5.1. For nearly two decades the truth values and null have been bona fide constants, first as regular built-in constants in PHP3. Later with the onset of the Zend Engine for PHP4,these constants were transformed into boolean constants. Just review the source code to learn the truth! And, the PHP Manual has finally corrected itself on this point, too.

By convention, one writes constants in uppercase and keywords in lowercase. The latest version of CodeIgniter (2.20) appears to dictate how one should express these constants:

TRUE, FALSE, and NULL keywords should always be fully uppercase.

from CodeIgniter Style Guide

like image 30
slevy1 Avatar answered Apr 22 '26 18:04

slevy1



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!