diff options
Diffstat (limited to 'user_guide/general')
-rw-r--r-- | user_guide/general/alternative_php.html | 4 | ||||
-rw-r--r-- | user_guide/general/creating_libraries.html | 2 | ||||
-rw-r--r-- | user_guide/general/credits.html | 4 | ||||
-rw-r--r-- | user_guide/general/drivers.html | 2 | ||||
-rw-r--r-- | user_guide/general/managing_apps.html | 6 | ||||
-rw-r--r-- | user_guide/general/models.html | 2 | ||||
-rw-r--r-- | user_guide/general/profiling.html | 4 | ||||
-rw-r--r-- | user_guide/general/styleguide.html | 124 | ||||
-rw-r--r-- | user_guide/general/views.html | 10 |
9 files changed, 79 insertions, 79 deletions
diff --git a/user_guide/general/alternative_php.html b/user_guide/general/alternative_php.html index b9069a8be..3193c0585 100644 --- a/user_guide/general/alternative_php.html +++ b/user_guide/general/alternative_php.html @@ -58,14 +58,14 @@ Alternate PHP Syntax <h1>Alternate PHP Syntax for View Files</h1> <p>If you do not utilize CodeIgniter's <a href="../libraries/parser.html">template engine</a>, you'll be using pure PHP -in your View files. To minimize the PHP code in these files, and to make it easier to identify the code blocks it is recommended that you use +in your View files. To minimize the PHP code in these files, and to make it easier to identify the code blocks it is recommended that you use PHPs alternative syntax for control structures and short tag echo statements. If you are not familiar with this syntax, it allows you to eliminate the braces from your code, and eliminate "echo" statements.</p> <h2>Automatic Short Tag Support</h2> <p><strong>Note:</strong> If you find that the syntax described in this page does not work on your server it might -be that "short tags" are disabled in your PHP ini file. CodeIgniter will optionally rewrite short tags on-the-fly, +be that "short tags" are disabled in your PHP ini file. CodeIgniter will optionally rewrite short tags on-the-fly, allowing you to use that syntax even if your server doesn't support it. This feature can be enabled in your <dfn>config/config.php</dfn> file.</p> diff --git a/user_guide/general/creating_libraries.html b/user_guide/general/creating_libraries.html index 0b4d642ae..3f0e32cb0 100644 --- a/user_guide/general/creating_libraries.html +++ b/user_guide/general/creating_libraries.html @@ -200,7 +200,7 @@ etc. <kbd>This is very important.</kbd> Assigning by reference allows you to use the original CodeIgniter object rather than creating a copy of it. <br /><br /> <kbd>Also, please note:</kbd> If you are running PHP 4 it's usually best to avoid calling <dfn>get_instance()</dfn> -from within your class constructors. PHP 4 has trouble referencing the CI super object within application constructors +from within your class constructors. PHP 4 has trouble referencing the CI super object within application constructors since objects do not exist until the class is fully instantiated.</p> diff --git a/user_guide/general/credits.html b/user_guide/general/credits.html index b77528a7e..5423d5838 100644 --- a/user_guide/general/credits.html +++ b/user_guide/general/credits.html @@ -58,8 +58,8 @@ Credits <h1>Credits</h1> <p>CodeIgniter was originally developed by <a href="http://www.ellislab.com/">Rick Ellis</a> (CEO of -<a href="http://ellislab.com/">EllisLab, Inc.</a>). The framework was written for performance in the real -world, with many of the class libraries, helpers, and sub-systems borrowed from the code-base of +<a href="http://ellislab.com/">EllisLab, Inc.</a>). The framework was written for performance in the real +world, with many of the class libraries, helpers, and sub-systems borrowed from the code-base of <a href="http://www.expressionengine.com/">ExpressionEngine</a>.</p> <p>It is currently developed and maintained by the ExpressionEngine Development Team.</p> diff --git a/user_guide/general/drivers.html b/user_guide/general/drivers.html index 9c86f0216..3163c11a7 100644 --- a/user_guide/general/drivers.html +++ b/user_guide/general/drivers.html @@ -75,7 +75,7 @@ Using CodeIgniter Drivers <code>$this->some_parent->some_method();</code> <p>The child classes, the drivers themselves, can then be called directly through the parent class, without initializing them:</p> - + <code>$this->some_parent->child_one->some_method();<br /> $this->some_parent->child_two->another_method();</code> diff --git a/user_guide/general/managing_apps.html b/user_guide/general/managing_apps.html index 04af6e6a3..a1a96cf82 100644 --- a/user_guide/general/managing_apps.html +++ b/user_guide/general/managing_apps.html @@ -70,7 +70,7 @@ file and set its name using the <samp>$application_folder</samp> variable:</p> <h2>Relocating your Application Folder</h2> -<p>It is possible to move your <dfn>application</dfn> folder to a different location on your server than your <kbd>system</kbd> folder. +<p>It is possible to move your <dfn>application</dfn> folder to a different location on your server than your <kbd>system</kbd> folder. To do so open your main <kbd>index.php</kbd> and set a <em>full server path</em> in the <samp>$application_folder</samp> variable.</p> @@ -79,7 +79,7 @@ To do so open your main <kbd>index.php</kbd> and set a <em>full server path</em> <h2>Running Multiple Applications with one CodeIgniter Installation</h2> -<p>If you would like to share a common CodeIgniter installation to manage several different applications simply +<p>If you would like to share a common CodeIgniter installation to manage several different applications simply put all of the directories located inside your <kbd>application</kbd> folder into their own sub-folder.</p> @@ -107,7 +107,7 @@ variable. For example, to select the "foo" application for use you would do thi <code>$application_folder = "applications/foo";</code> -<p class="important"><strong>Note:</strong> Each of your applications will need its own <dfn>index.php</dfn> file which +<p class="important"><strong>Note:</strong> Each of your applications will need its own <dfn>index.php</dfn> file which calls the desired application. The index.php file can be named anything you want.</p> diff --git a/user_guide/general/models.html b/user_guide/general/models.html index e405dd1b6..35ab08d20 100644 --- a/user_guide/general/models.html +++ b/user_guide/general/models.html @@ -212,7 +212,7 @@ class Blog_controller extends Controller {<br /> <li>You can tell the model loading function to auto-connect by passing <kbd>TRUE</kbd> (boolean) via the third parameter, and connectivity settings, as defined in your database config file will be used: - <code>$this->load->model('<var>Model_name</var>', '', <kbd>TRUE</kbd>);</code> + <code>$this->load->model('<var>Model_name</var>', '', <kbd>TRUE</kbd>);</code> </li> diff --git a/user_guide/general/profiling.html b/user_guide/general/profiling.html index 47c1a5abc..7cb3f158d 100644 --- a/user_guide/general/profiling.html +++ b/user_guide/general/profiling.html @@ -129,7 +129,7 @@ This information can be useful during development in order to help with debuggin <td class="td">Any GET data passed in the request</td> <td class="td">TRUE</td> </tr><tr> - + <td class="td"><strong>http_headers</strong></td> <td class="td">The HTTP headers for the current request</td> <td class="td">TRUE</td> @@ -149,7 +149,7 @@ This information can be useful during development in order to help with debuggin <td class="td">Listing of all database queries executed, including execution time</td> <td class="td">TRUE</td> </tr><tr> - + <td class="td"><strong>uri_string</strong></td> <td class="td">The URI of the current request</td> <td class="td">TRUE</td> diff --git a/user_guide/general/styleguide.html b/user_guide/general/styleguide.html index 1200a2c12..7b7d837d9 100644 --- a/user_guide/general/styleguide.html +++ b/user_guide/general/styleguide.html @@ -107,12 +107,12 @@ Style Guide a UTF-8 encoded file, and the <abbr title="Byte Order Mark">BOM</abbr> can have a negative side effect in PHP of sending output, preventing the application from being able to set its own headers. Unix line endings should be used (LF).</p> - + <p>Here is how to apply these settings in some of the more common text editors. Instructions for your text editor may vary; check your text editor's documentation.</p> - + <h5>TextMate</h5> - + <ol> <li>Open the Application Preferences</li> <li>Click Advanced, and then the "Saving" tab</li> @@ -121,9 +121,9 @@ Style Guide <li><em>Optional:</em> Check "Use for existing files as well" if you wish to modify the line endings of files you open to your new preference.</li> </ol> - + <h5>BBEdit</h5> - + <ol> <li>Open the Application Preferences</li> <li>Select "Text Encodings" on the left.</li> @@ -137,7 +137,7 @@ Style Guide <h2><a name="php_closing_tag"></a>PHP Closing Tag</h2> <div class="guidelineDetails"> - <p>The PHP closing tag on a PHP document <strong>?></strong> is optional to the PHP parser. However, if used, any whitespace following the closing tag, whether introduced + <p>The PHP closing tag on a PHP document <strong>?></strong> is optional to the PHP parser. However, if used, any whitespace following the closing tag, whether introduced by the developer, user, or an FTP application, can cause unwanted output, PHP errors, or if the latter are suppressed, blank pages. For this reason, all PHP files should <strong>OMIT</strong> the closing PHP tag, and instead use a comment block to mark the end of file and it's location relative to the application root. This allows you to still identify a file as being complete and not truncated.</p> @@ -158,7 +158,7 @@ echo "Here's my code!"; </code> </div> - + <h2><a name="class_and_method_naming"></a>Class and Method Naming</h2> <div class="guidelineDetails"> <p>Class names should always have their first letter uppercase, and the constructor method should match identically. Multiple words should be separated with an underscore, and not CamelCased. All other class methods should be entirely lowercased and named to clearly indicate their function, preferably including a verb. Try to avoid overly long and verbose names.</p> @@ -193,8 +193,8 @@ function get_the_file_properties_from_the_file() // wordy function get_file_properties() // descriptive, underscore separator, and all lowercase letters</code> </div> - - + + <h2><a name="variable_names"></a>Variable Names</h2> <div class="guidelineDetails"> <p>The guidelines for variable naming is very similar to that used for class methods. Namely, variables should contain only lowercase letters, use underscore separators, and be reasonably named to indicate their purpose and contents. Very short, non-word variables should only be used as iterators in for() loops.</p> @@ -213,8 +213,8 @@ $group_id $last_city </code> </div> - - + + <h2><a name="commenting"></a>Commenting</h2> <div class="guidelineDetails"> <p>In general, code should be commented prolifically. It not only helps describe the flow and intent of the code for less experienced programmers, but can prove invaluable when returning to your own code months down the line. There is not a required format for comments, but the following are recommended.</p> @@ -257,8 +257,8 @@ $parts = explode("\n", $str); $parts = $this->foo($parts); </code> </div> - - + + <h2><a name="constants"></a>Constants</h2> <div class="guidelineDetails"> <p>Constants follow the same guidelines as do variables, except constants should always be fully uppercase. <em>Always use CodeIgniter constants when appropriate, i.e. SLASH, LD, RD, PATH_CACHE, etc.</em></p> @@ -275,8 +275,8 @@ SUPER_CLASS_VERSION $str = str_replace(LD.'foo'.RD, 'bar', $str); </code> </div> - - + + <h2><a name="true_false_and_null"></a>TRUE, FALSE, and NULL</h2> <div class="guidelineDetails"> <p><strong>TRUE</strong>, <strong>FALSE</strong>, and <strong>NULL</strong> keywords should always be fully uppercase.</p> @@ -290,9 +290,9 @@ if ($foo == TRUE) $bar = FALSE; function foo($bar = NULL)</code> </div> - - + + <h2><a name="logical_operators"></a>Logical Operators</h2> <div class="guidelineDetails"> <p>Use of <strong>||</strong> is discouraged as its clarity on some output devices is low (looking like the number 11 for instance). @@ -310,9 +310,9 @@ if ( ! $foo) if ( ! is_array($foo)) </code> </div> - - - + + + <h2><a name="comparing_return_values_and_typecasting"></a>Comparing Return Values and Typecasting</h2> <div class="guidelineDetails"> <p>Some PHP functions return FALSE on failure, but may also have a valid return value of "" or 0, which would evaluate to FALSE in loose comparisons. Be explicit by comparing the variable type when using these return values in conditionals to ensure the return value is indeed what you expect, and not a value that has an equivalent loose-type evaluation.</p> @@ -350,27 +350,27 @@ function build_string($str = "") <code>$str = (string) $str; // cast $str as a string</code> </div> - - + + <h2><a name="debugging_code"></a>Debugging Code</h2> <div class="guidelineDetails"> <p>No debugging code can be left in place for submitted add-ons unless it is commented out, i.e. no var_dump(), print_r(), die(), and exit() calls that were used while creating the add-on, unless they are commented out.</p> <code>// print_r($foo);</code> </div> - - + + <h2><a name="whitespace_in_files"></a>Whitespace in Files</h2> <div class="guidelineDetails"> <p>No whitespace can precede the opening PHP tag or follow the closing PHP tag. Output is buffered, so whitespace in your files can cause output to begin before CodeIgniter outputs its content, leading to errors and an inability for CodeIgniter to send proper headers. In the examples below, select the text with your mouse to reveal the incorrect whitespace.</p> <p><strong>INCORRECT</strong>:</p> -<code> +<code> <?php // ...there is whitespace and a linebreak above the opening PHP tag // as well as whitespace after the closing PHP tag -?> +?> </code> <p><strong>CORRECT</strong>:</p> <code><?php @@ -378,15 +378,15 @@ function build_string($str = "") ?></code> </div> - - + + <h2><a name="compatibility"></a>Compatibility</h2> <div class="guidelineDetails"> <p>Unless specifically mentioned in your add-on's documentation, all code must be compatible with PHP version 4.3+. Additionally, do not use PHP functions that require non-default libraries to be installed unless your code contains an alternative method when the function is not available, or you implicitly document that your add-on requires said PHP libraries.</p> </div> - - + + <h2><a name="class_and_file_names_using_common_words"></a>Class and File Names using Common Words</h2> <div class="guidelineDetails"> <p>When your class or filename is a common word, or might quite likely be identically named in another PHP script, provide a unique prefix to help prevent collision. Always realize that your end users may be running other add-ons or third party PHP scripts. Choose a prefix that is unique to your identity as a developer or company.</p> @@ -402,8 +402,8 @@ class Pre_xml ext.pre_xml.php class Pre_import mod.pre_import.php </code> </div> - - + + <h2><a name="database_table_names"></a>Database Table Names</h2> <div class="guidelineDetails"> <p>Any tables that your add-on might use must use the 'exp_' prefix, followed by a prefix uniquely identifying you as the developer or company, and then a short descriptive table name. You do not need to be concerned about the database prefix being used on the user's installation, as CodeIgniter's database class will automatically convert 'exp_' to what is actually being used.</p> @@ -419,30 +419,30 @@ exp_pre_email_addresses <p class="important"><strong>NOTE:</strong> Be mindful that MySQL has a limit of 64 characters for table names. This should not be an issue as table names that would exceed this would likely have unreasonable names. For instance, the following table name exceeds this limitation by one character. Silly, no? <strong>exp_pre_email_addresses_of_registered_users_in_seattle_washington</strong> </div> - - + + <h2><a name="one_file_per_class"></a>One File per Class</h2> <div class="guidelineDetails"> <p>Use separate files for each class your add-on uses, unless the classes are <em>closely related</em>. An example of CodeIgniter files that contains multiple classes is the Database class file, which contains both the DB class and the DB_Cache class, and the Magpie plugin, which contains both the Magpie and Snoopy classes.</p> </div> - - + + <h2><a name="whitespace"></a>Whitespace</h2> <div class="guidelineDetails"> <p>Use tabs for whitespace in your code, not spaces. This may seem like a small thing, but using tabs instead of whitespace allows the developer looking at your code to have indentation at levels that they prefer and customize in whatever application they use. And as a side benefit, it results in (slightly) more compact files, storing one tab character versus, say, four space characters.</p> </div> - - + + <h2><a name="line_breaks"></a>Line Breaks</h2> <div class="guidelineDetails"> <p>Files must be saved with Unix line breaks. This is more of an issue for developers who work in Windows, but in any case ensure that your text editor is setup to save files with Unix line breaks.</p> </div> - - + + <h2><a name="code_indenting"></a>Code Indenting</h2> <div class="guidelineDetails"> <p>Use Allman style indenting. With the exception of Class declarations, braces are always placed on a line by themselves, and indented at the same level as the control statement that "owns" them.</p> @@ -498,12 +498,12 @@ for ($i = 0; $i < 10; $i++) } }</code> </div> - + <h2><a name="bracket_spacing"></a>Bracket and Parenthetic Spacing</h2> <div class="guidelineDetails"> <p>In general, parenthesis and brackets should not use any additional spaces. The exception is that a space should always follow PHP control structures that accept arguments with parenthesis (declare, do-while, elseif, for, foreach, if, switch, while), to help distinguish them from functions and increase readability.</p> - + <code>INCORRECT: $arr[ $foo ] = 'foo'; @@ -514,13 +514,13 @@ $arr[$foo] = 'foo'; // no spaces around array keys INCORRECT: function foo ( $bar ) { - + } CORRECT: function foo($bar) // no spaces around parenthesis in function declarations { - + } @@ -531,9 +531,9 @@ CORRECT: foreach ($query->result() as $row) // single space following PHP control structures, but not in interior parenthesis </code> </div> - - - + + + <h2><a name="localized_text"></a>Localized Text</h2> <div class="guidelineDetails"> <p>Any text that is output in the control panel should use language variables in your lang file to allow localization.</p> @@ -544,9 +544,9 @@ return "Invalid Selection"; CORRECT: return $this->lang->line('invalid_selection');</code> </div> - - + + <h2><a name="private_methods_and_variables"></a>Private Methods and Variables</h2> <div class="guidelineDetails"> <p>Methods and variables that are only accessed internally by your class, such as utility and helper functions that your public methods use for code abstraction, should be prefixed with an underscore.</p> @@ -554,9 +554,9 @@ return $this->lang->line('invalid_selection');</code> <code>convert_text() // public method _convert_text() // private method</code> </div> - - + + <h2><a name="php_errors"></a>PHP Errors</h2> <div class="guidelineDetails"> <p>Code must run error free and not rely on warnings and notices to be hidden to meet this requirement. For instance, never access a variable that you did not set yourself (such as $_POST array keys) without first checking to see that it isset().</p> @@ -574,9 +574,9 @@ _convert_text() // private method</code> <p class="important"><strong>NOTE:</strong> Setting the <a href="http://us.php.net/manual/en/ref.errorfunc.php#ini.display-errors">display_errors</a> setting with ini_set() at runtime is not identical to having it enabled in the PHP environment. Namely, it will not have any effect if the script has fatal errors</p> </div> - - + + <h2><a name="short_open_tags"></a>Short Open Tags</h2> <div class="guidelineDetails"> <p>Always use full PHP opening tags, in case a server does not have short_open_tag enabled.</p> @@ -589,9 +589,9 @@ _convert_text() // private method</code> <strong>CORRECT</strong>: <?php echo $foo; ?></code> </div> - - + + <h2><a name="one_statement_per_line"></a>One Statement Per Line</h2> <div class="guidelineDetails"> <p>Never combine statements on one line.</p> @@ -605,9 +605,9 @@ $bar = 'that'; $bat = str_replace($foo, $bar, $bag); </code> </div> - - + + <h2><a name="strings"></a>Strings</h2> <div class="guidelineDetails"> <p>Always use single quoted strings unless you need variables parsed, and in cases where you do need variables parsed, use braces to prevent greedy token parsing. You may also use double-quoted strings if the string contains single quotes, so you do not have to use escape characters.</p> @@ -622,9 +622,9 @@ $bat = str_replace($foo, $bar, $bag); "My string {$foo}" "SELECT foo FROM bar WHERE baz = 'bag'"</code> </div> - - + + <h2><a name="sql_queries"></a>SQL Queries</h2> <div class="guidelineDetails"> <p>MySQL keywords are always capitalized: SELECT, INSERT, UPDATE, WHERE, AS, JOIN, ON, IN, etc.</p> @@ -645,16 +645,16 @@ $query = $this->db->query("SELECT foo, bar, baz, foofoo, foobar AS raboof, fooba ORDER BY foobaz LIMIT 5, 100");</code> </div> - - + + <h2><a name="default_function_arguments"></a>Default Function Arguments</h2> <div class="guidelineDetails"> <p>Whenever appropriate, provide function argument defaults, which helps prevent PHP errors with mistaken calls and provides common fallback values which can save a few lines of code. Example:</p> <code>function foo($bar = '', $baz = FALSE)</code> </div> - + </div> diff --git a/user_guide/general/views.html b/user_guide/general/views.html index b5dea05a1..8f317109e 100644 --- a/user_guide/general/views.html +++ b/user_guide/general/views.html @@ -169,7 +169,7 @@ class Blog extends Controller { { $data['title'] = "My Real Title"; $data['heading'] = "My Real Heading"; - + $this->load->view('blogview', $data); } } @@ -211,7 +211,7 @@ class Blog extends Controller { $data['title'] = "My Real Title"; $data['heading'] = "My Real Heading"; - + $this->load->view('blogview', $data); } } @@ -229,8 +229,8 @@ class Blog extends Controller { </head> <body> <h1><?php echo $heading;?></h1> - -<h3>My Todo List</h3> + +<h3>My Todo List</h3> <ul> <?php foreach($todo_list as $item):?> @@ -239,7 +239,7 @@ class Blog extends Controller { <?php endforeach;?> </ul> - + </body> </html> </textarea> |