CI NOTE 2

Source: Internet
Author: User

Debug mode on, $this->output->enable_profiler (TRUE);

Reserved word, cannot and controller name , there are 3 ,Ci_controller, Default, index. These three names cannot be in the name of the controller. In the directory of Controllers index.php and default.php, ci_controller.php these three names cannot have.

Naming conventions:

the name of the class begins with uppercase, with no hump named, and multiple words underlined. such as Class Some_class {}

class methods, all in lowercase, and indicate the function of the method, preferably including a verb, multiple words underlined , avoid too long. such as function get_file_properties ()

The names of variables , like classes, all "lowercase" and "underscores", indicate the purpose of the variable, and the very short meaningless name is used for iteration in the For loop.

Comments, using DocBlock-style, single-line comments and code, should leave a blank line between a chunk of gaze and code.

names of constants, all with "uppercase" and "Underline ", use the CI framework has defined constants, such as Slash,ld,rd,path_cache, etc.

true,false,null, these keywords are all capitalized.

Logical operators, avoid using | | Use OR, avoid and, use &&; After that, add a space.

When you return a value comparison, when some PHP functions return false, you might return a valid value such as "" or "0", which are equal when the loosely-typed comparison and false, so you must use "= = =" or "!==" when comparing the conditions, anddo not use "= =" or "! ="

The spaces in the file, before "<?php" and "?>", do not have spaces , the output is cached, and a blank space causes the header output error.

The code indents, using the Allman Code style, with curly braces in addition to the definition of the class, with the other curly braces taking on a separate line.

parentheses and spaces in brackets do not use extra spaces unless they are in the middle of the control statement.

Do not use short marks, with full markings, <?php?>

string in single quotation marks, when there is a variable $ in the string in double quotation marks, and curly braces to wrap the variable, such as "My string is {$foo}", if there is a single quotation mark in the string, in order to avoid using the escape character, use double quotation marks.

SQL query statement, using uppercase keywords.

Default function parameters, it is best to provide default values . function ($foo = ", $baz = FALSE)

The equals sign "=" has a space on both sides , a comma "," there is no space before the face has a space .

CI NOTE 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.