summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/general/styleguide.rst
diff options
context:
space:
mode:
Diffstat (limited to 'user_guide_src/source/general/styleguide.rst')
-rw-r--r--user_guide_src/source/general/styleguide.rst42
1 files changed, 20 insertions, 22 deletions
diff --git a/user_guide_src/source/general/styleguide.rst b/user_guide_src/source/general/styleguide.rst
index 925954c03..7c0a59791 100644
--- a/user_guide_src/source/general/styleguide.rst
+++ b/user_guide_src/source/general/styleguide.rst
@@ -168,11 +168,11 @@ picked up by IDEs::
/**
* Encodes string for use in XML
*
- * @param string
+ * @param string $str Input string
* @return string
*/
function xml_encode($str)
-
+
::
/**
@@ -180,9 +180,7 @@ picked up by IDEs::
*
* @var array
*/
- public $data
-
-
+ public $data = array();
Use single line comments within code, leaving a blank line between large
comment blocks and code.
@@ -308,8 +306,8 @@ Use **===** and **!==** as necessary.
}
-See also information regarding
-`typecasting <http://us3.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting>`_,
+See also information regarding `typecasting
+<http://php.net/manual/en/language.types.type-juggling.php#language.types.typecasting>`_,
which can be quite useful. Typecasting has a slightly different effect
which may be desirable. When casting a variable as a string, for
instance, NULL and boolean FALSE variables become empty strings, 0 (and
@@ -338,7 +336,6 @@ 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.
-
Compatibility
=============
@@ -559,16 +556,16 @@ code abstraction, should be prefixed with an underscore.
::
- convert_text() // public method
- _convert_text() // private method
+ public function convert_text()
+ private function _convert_text()
PHP Errors
==========
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().
+that you did not set yourself (such as ``$_POST`` array keys) without first
+checking to see that it ``isset()``.
Make sure that while developing your add-on, error reporting is enabled
for ALL users, and that display_errors is enabled in the PHP
@@ -579,22 +576,22 @@ environment. You can check this setting with::
exit "Enabled";
}
-On some servers where display_errors is disabled, and you do not have
+On some servers where *display_errors* is disabled, and you do not have
the ability to change this in the php.ini, you can often enable it with::
ini_set('display_errors', 1);
-**NOTE:** Setting the
-`display_errors <http://us.php.net/manual/en/ref.errorfunc.php#ini.display-errors>`_
-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
+.. note:: Setting the `display_errors
+ <http://php.net/manual/en/ref.errorfunc.php#ini.display-errors>`_
+ 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.
Short Open Tags
===============
Always use full PHP opening tags, in case a server does not have
-short_open_tag enabled.
+*short_open_tag* enabled.
**INCORRECT**::
@@ -606,6 +603,8 @@ short_open_tag enabled.
<?php echo $foo; ?>
+.. note:: PHP 5.4 will always have the **<?=** tag available.
+
One Statement Per Line
======================
@@ -645,7 +644,7 @@ characters.
SQL Queries
===========
-MySQL keywords are always capitalized: SELECT, INSERT, UPDATE, WHERE,
+SQL keywords are always capitalized: SELECT, INSERT, UPDATE, WHERE,
AS, JOIN, ON, IN, etc.
Break up long queries into multiple lines for legibility, preferably
@@ -674,5 +673,4 @@ 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::
- function foo($bar = '', $baz = FALSE)
-
+ function foo($bar = '', $baz = FALSE) \ No newline at end of file