blob: 99bc056f7dbb64b0400567da1cb4326b6b277977 [file] [log] [blame]
Derek Jones619b1222011-10-10 16:26:27 -05001###############
2PHP Style Guide
3###############
4
Derek Jones8ede1a22011-10-05 13:34:52 -05005
6The following page describes the use of coding rules adhered to when
7developing CodeIgniter.
8
9.. contents:: Table of Contents
10
11File Format
12===========
13
14Files should be saved with Unicode (UTF-8) encoding. The BOM should
15*not* be used. Unlike UTF-16 and UTF-32, there's no byte order to
16indicate in a UTF-8 encoded file, and the BOM can have a negative side
17effect in PHP of sending output, preventing the application from being
18able to set its own headers. Unix line endings should be used (LF).
19
20Here is how to apply these settings in some of the more common text
21editors. Instructions for your text editor may vary; check your text
22editor's documentation.
23
24TextMate
25''''''''
26
27#. Open the Application Preferences
28#. Click Advanced, and then the "Saving" tab
29#. In "File Encoding", select "UTF-8 (recommended)"
30#. In "Line Endings", select "LF (recommended)"
31#. *Optional:* Check "Use for existing files as well" if you wish to
32 modify the line endings of files you open to your new preference.
33
34BBEdit
35''''''
36
37#. Open the Application Preferences
38#. Select "Text Encodings" on the left.
39#. In "Default text encoding for new documents", select "Unicode (UTF-8,
40 no BOM)"
41#. *Optional:* In "If file's encoding can't be guessed, use", select
42 "Unicode (UTF-8, no BOM)"
43#. Select "Text Files" on the left.
44#. In "Default line breaks", select "Mac OS X and Unix (LF)"
45
46PHP Closing Tag
47===============
48
49The PHP closing tag on a PHP document **?>** is optional to the PHP
50parser. However, if used, any whitespace following the closing tag,
51whether introduced by the developer, user, or an FTP application, can
52cause unwanted output, PHP errors, or if the latter are suppressed,
53blank pages. For this reason, all PHP files should **OMIT** the closing
54PHP tag, and instead use a comment block to mark the end of file and
Andrey Andreev93f5c5d2012-11-22 13:26:07 +020055its location relative to the application root. This allows you to still
Derek Jones8ede1a22011-10-05 13:34:52 -050056identify a file as being complete and not truncated.
57
Derek Jones129c1812011-10-05 17:15:44 -050058**INCORRECT**::
Derek Jones8ede1a22011-10-05 13:34:52 -050059
Derek Jones129c1812011-10-05 17:15:44 -050060 <?php
61
62 echo "Here's my code!";
63
64 ?>
65
66**CORRECT**::
67
68 <?php
69
70 echo "Here's my code!";
71
72 /* End of file myfile.php */
73 /* Location: ./system/modules/mymodule/myfile.php */
Derek Jones8ede1a22011-10-05 13:34:52 -050074
75Class and Method Naming
76=======================
77
78Class names should always start with an uppercase letter. Multiple words
79should be separated with an underscore, and not CamelCased. All other
80class methods should be entirely lowercased and named to clearly
81indicate their function, preferably including a verb. Try to avoid
82overly long and verbose names.
83
Derek Jones129c1812011-10-05 17:15:44 -050084**INCORRECT**::
Derek Jones8ede1a22011-10-05 13:34:52 -050085
Derek Jones129c1812011-10-05 17:15:44 -050086 class superclass
87 class SuperClass
88
89**CORRECT**::
90
91 class Super_class
Derek Jones8ede1a22011-10-05 13:34:52 -050092
93::
94
Derek Jones129c1812011-10-05 17:15:44 -050095 class Super_class {
Derek Jones8ede1a22011-10-05 13:34:52 -050096
Andrey Andreevd8e1ac72012-03-26 22:22:37 +030097 public function __construct()
Derek Jones129c1812011-10-05 17:15:44 -050098 {
Derek Jones8ede1a22011-10-05 13:34:52 -050099
Derek Jones129c1812011-10-05 17:15:44 -0500100 }
101 }
102
103Examples of improper and proper method naming:
104
105**INCORRECT**::
106
107 function fileproperties() // not descriptive and needs underscore separator
108 function fileProperties() // not descriptive and uses CamelCase
109 function getfileproperties() // Better! But still missing underscore separator
110 function getFileProperties() // uses CamelCase
111 function get_the_file_properties_from_the_file() // wordy
112
113**CORRECT**::
114
115 function get_file_properties() // descriptive, underscore separator, and all lowercase letters
Derek Jones8ede1a22011-10-05 13:34:52 -0500116
117Variable Names
118==============
119
120The guidelines for variable naming is very similar to that used for
121class methods. Namely, variables should contain only lowercase letters,
122use underscore separators, and be reasonably named to indicate their
123purpose and contents. Very short, non-word variables should only be used
124as iterators in for() loops.
125
Derek Jones129c1812011-10-05 17:15:44 -0500126**INCORRECT**::
Derek Jones8ede1a22011-10-05 13:34:52 -0500127
Derek Jones129c1812011-10-05 17:15:44 -0500128 $j = 'foo'; // single letter variables should only be used in for() loops
129 $Str // contains uppercase letters
130 $bufferedText // uses CamelCasing, and could be shortened without losing semantic meaning
131 $groupid // multiple words, needs underscore separator
132 $name_of_last_city_used // too long
133
134**CORRECT**::
135
136 for ($j = 0; $j < 10; $j++)
137 $str
138 $buffer
139 $group_id
140 $last_city
Derek Jones8ede1a22011-10-05 13:34:52 -0500141
142Commenting
143==========
144
145In general, code should be commented prolifically. It not only helps
146describe the flow and intent of the code for less experienced
147programmers, but can prove invaluable when returning to your own code
148months down the line. There is not a required format for comments, but
149the following are recommended.
150
151`DocBlock <http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#basics.docblock>`_
Timothy Warrenbb8ae012012-04-20 10:31:51 -0400152style comments preceding class, method, and property declarations so they can be
Derek Jones8ede1a22011-10-05 13:34:52 -0500153picked up by IDEs::
154
Derek Jones129c1812011-10-05 17:15:44 -0500155 /**
156 * Super Class
157 *
158 * @package Package Name
159 * @subpackage Subpackage
160 * @category Category
161 * @author Author Name
162 * @link http://example.com
163 */
164 class Super_class {
Derek Jones8ede1a22011-10-05 13:34:52 -0500165
166::
167
Derek Jones129c1812011-10-05 17:15:44 -0500168 /**
169 * Encodes string for use in XML
170 *
Andrey Andreev16a704c2012-11-09 17:25:00 +0200171 * @param string $str Input string
Derek Jones129c1812011-10-05 17:15:44 -0500172 * @return string
173 */
174 function xml_encode($str)
Andrey Andreev16a704c2012-11-09 17:25:00 +0200175
Timothy Warrenbb8ae012012-04-20 10:31:51 -0400176::
177
178 /**
179 * Data for class manipulation
180 *
181 * @var array
182 */
Andrey Andreev16a704c2012-11-09 17:25:00 +0200183 public $data = array();
Derek Jones8ede1a22011-10-05 13:34:52 -0500184
185Use single line comments within code, leaving a blank line between large
186comment blocks and code.
187
188::
189
Derek Jones129c1812011-10-05 17:15:44 -0500190 // break up the string by newlines
191 $parts = explode("\n", $str);
192
193 // A longer comment that needs to give greater detail on what is
194 // occurring and why can use multiple single-line comments. Try to
195 // keep the width reasonable, around 70 characters is the easiest to
196 // read. Don't hesitate to link to permanent external resources
197 // that may provide greater detail:
198 //
199 // http://example.com/information_about_something/in_particular/
200
201 $parts = $this->foo($parts);
Derek Jones8ede1a22011-10-05 13:34:52 -0500202
203Constants
204=========
205
206Constants follow the same guidelines as do variables, except constants
207should always be fully uppercase. *Always use CodeIgniter constants when
208appropriate, i.e. SLASH, LD, RD, PATH_CACHE, etc.*
209
Derek Jones129c1812011-10-05 17:15:44 -0500210**INCORRECT**::
Derek Jones8ede1a22011-10-05 13:34:52 -0500211
Derek Jones129c1812011-10-05 17:15:44 -0500212 myConstant // missing underscore separator and not fully uppercase
213 N // no single-letter constants
214 S_C_VER // not descriptive
215 $str = str_replace('{foo}', 'bar', $str); // should use LD and RD constants
216
217**CORRECT**::
218
219 MY_CONSTANT
220 NEWLINE
221 SUPER_CLASS_VERSION
222 $str = str_replace(LD.'foo'.RD, 'bar', $str);
Derek Jones8ede1a22011-10-05 13:34:52 -0500223
224TRUE, FALSE, and NULL
225=====================
226
227**TRUE**, **FALSE**, and **NULL** keywords should always be fully
228uppercase.
229
Derek Jones129c1812011-10-05 17:15:44 -0500230**INCORRECT**::
Derek Jones8ede1a22011-10-05 13:34:52 -0500231
Derek Jones129c1812011-10-05 17:15:44 -0500232 if ($foo == true)
233 $bar = false;
234 function foo($bar = null)
235
236**CORRECT**::
237
238 if ($foo == TRUE)
239 $bar = FALSE;
240 function foo($bar = NULL)
Derek Jones8ede1a22011-10-05 13:34:52 -0500241
242Logical Operators
243=================
244
245Use of **\|\|** is discouraged as its clarity on some output devices is
246low (looking like the number 11 for instance). **&&** is preferred over
247**AND** but either are acceptable, and a space should always precede and
248follow **!**.
249
Derek Jones129c1812011-10-05 17:15:44 -0500250**INCORRECT**::
Derek Jones8ede1a22011-10-05 13:34:52 -0500251
Derek Jones129c1812011-10-05 17:15:44 -0500252 if ($foo || $bar)
253 if ($foo AND $bar) // okay but not recommended for common syntax highlighting applications
254 if (!$foo)
255 if (! is_array($foo))
256
257**CORRECT**::
258
259 if ($foo OR $bar)
260 if ($foo && $bar) // recommended
261 if ( ! $foo)
262 if ( ! is_array($foo))
263
Derek Jones8ede1a22011-10-05 13:34:52 -0500264
265Comparing Return Values and Typecasting
266=======================================
267
268Some PHP functions return FALSE on failure, but may also have a valid
269return value of "" or 0, which would evaluate to FALSE in loose
270comparisons. Be explicit by comparing the variable type when using these
271return values in conditionals to ensure the return value is indeed what
272you expect, and not a value that has an equivalent loose-type
273evaluation.
274
275Use the same stringency in returning and checking your own variables.
276Use **===** and **!==** as necessary.
Derek Jones8ede1a22011-10-05 13:34:52 -0500277
Derek Jones129c1812011-10-05 17:15:44 -0500278**INCORRECT**::
Derek Jones8ede1a22011-10-05 13:34:52 -0500279
Derek Jones129c1812011-10-05 17:15:44 -0500280 // If 'foo' is at the beginning of the string, strpos will return a 0,
281 // resulting in this conditional evaluating as TRUE
282 if (strpos($str, 'foo') == FALSE)
Derek Jones8ede1a22011-10-05 13:34:52 -0500283
Derek Jones129c1812011-10-05 17:15:44 -0500284**CORRECT**::
285
286 if (strpos($str, 'foo') === FALSE)
287
288**INCORRECT**::
289
290 function build_string($str = "")
291 {
292 if ($str == "") // uh-oh! What if FALSE or the integer 0 is passed as an argument?
293 {
294
295 }
296 }
297
298**CORRECT**::
299
300 function build_string($str = "")
301 {
302 if ($str === "")
303 {
304
305 }
306 }
Derek Jones8ede1a22011-10-05 13:34:52 -0500307
308
Andrey Andreev16a704c2012-11-09 17:25:00 +0200309See also information regarding `typecasting
310<http://php.net/manual/en/language.types.type-juggling.php#language.types.typecasting>`_,
Derek Jones8ede1a22011-10-05 13:34:52 -0500311which can be quite useful. Typecasting has a slightly different effect
312which may be desirable. When casting a variable as a string, for
313instance, NULL and boolean FALSE variables become empty strings, 0 (and
314other numbers) become strings of digits, and boolean TRUE becomes "1"::
315
316 $str = (string) $str; // cast $str as a string
317
318Debugging Code
319==============
320
321No debugging code can be left in place for submitted add-ons unless it
322is commented out, i.e. no var_dump(), print_r(), die(), and exit()
323calls that were used while creating the add-on, unless they are
324commented out.
325
326::
327
328 // print_r($foo);
329
330Whitespace in Files
331===================
332
333No whitespace can precede the opening PHP tag or follow the closing PHP
334tag. Output is buffered, so whitespace in your files can cause output to
335begin before CodeIgniter outputs its content, leading to errors and an
336inability for CodeIgniter to send proper headers. In the examples below,
337select the text with your mouse to reveal the incorrect whitespace.
338
Derek Jones8ede1a22011-10-05 13:34:52 -0500339Compatibility
340=============
341
342Unless specifically mentioned in your add-on's documentation, all code
343must be compatible with PHP version 5.1+. Additionally, do not use PHP
344functions that require non-default libraries to be installed unless your
345code contains an alternative method when the function is not available,
346or you implicitly document that your add-on requires said PHP libraries.
347
348Class and File Names using Common Words
349=======================================
350
351When your class or filename is a common word, or might quite likely be
352identically named in another PHP script, provide a unique prefix to help
353prevent collision. Always realize that your end users may be running
354other add-ons or third party PHP scripts. Choose a prefix that is unique
355to your identity as a developer or company.
356
Derek Jones129c1812011-10-05 17:15:44 -0500357**INCORRECT**::
Derek Jones8ede1a22011-10-05 13:34:52 -0500358
Derek Jones129c1812011-10-05 17:15:44 -0500359 class Email pi.email.php
360 class Xml ext.xml.php
361 class Import mod.import.php
362
363**CORRECT**::
364
365 class Pre_email pi.pre_email.php
366 class Pre_xml ext.pre_xml.php
367 class Pre_import mod.pre_import.php
Derek Jones8ede1a22011-10-05 13:34:52 -0500368
369Database Table Names
370====================
371
372Any tables that your add-on might use must use the 'exp\_' prefix,
373followed by a prefix uniquely identifying you as the developer or
374company, and then a short descriptive table name. You do not need to be
375concerned about the database prefix being used on the user's
376installation, as CodeIgniter's database class will automatically convert
377'exp\_' to what is actually being used.
378
Derek Jones129c1812011-10-05 17:15:44 -0500379**INCORRECT**::
Derek Jones8ede1a22011-10-05 13:34:52 -0500380
Derek Jones129c1812011-10-05 17:15:44 -0500381 email_addresses // missing both prefixes
382 pre_email_addresses // missing exp_ prefix
383 exp_email_addresses // missing unique prefix
Derek Jones8ede1a22011-10-05 13:34:52 -0500384
Derek Jones129c1812011-10-05 17:15:44 -0500385**CORRECT**::
386
387 exp_pre_email_addresses
388
389.. note:: Be mindful that MySQL has a limit of 64 characters for table
390 names. This should not be an issue as table names that would exceed this
391 would likely have unreasonable names. For instance, the following table
392 name exceeds this limitation by one character. Silly, no?
393 **exp_pre_email_addresses_of_registered_users_in_seattle_washington**
394
Derek Jones8ede1a22011-10-05 13:34:52 -0500395One File per Class
396==================
397
398Use separate files for each class your add-on uses, unless the classes
399are *closely related*. An example of CodeIgniter files that contains
400multiple classes is the Database class file, which contains both the DB
401class and the DB_Cache class, and the Magpie plugin, which contains
402both the Magpie and Snoopy classes.
403
404Whitespace
405==========
406
407Use tabs for whitespace in your code, not spaces. This may seem like a
408small thing, but using tabs instead of whitespace allows the developer
409looking at your code to have indentation at levels that they prefer and
410customize in whatever application they use. And as a side benefit, it
411results in (slightly) more compact files, storing one tab character
412versus, say, four space characters.
413
414Line Breaks
415===========
416
417Files must be saved with Unix line breaks. This is more of an issue for
418developers who work in Windows, but in any case ensure that your text
419editor is setup to save files with Unix line breaks.
420
421Code Indenting
422==============
423
424Use Allman style indenting. With the exception of Class declarations,
425braces are always placed on a line by themselves, and indented at the
426same level as the control statement that "owns" them.
427
Derek Jones129c1812011-10-05 17:15:44 -0500428**INCORRECT**::
Derek Jones8ede1a22011-10-05 13:34:52 -0500429
Derek Jones129c1812011-10-05 17:15:44 -0500430 function foo($bar) {
431 // ...
432 }
433
434 foreach ($arr as $key => $val) {
435 // ...
436 }
437
438 if ($foo == $bar) {
439 // ...
440 } else {
441 // ...
442 }
443
444 for ($i = 0; $i < 10; $i++)
445 {
446 for ($j = 0; $j < 10; $j++)
447 {
448 // ...
449 }
450 }
Timothy Warren82c83072012-01-26 19:02:05 -0500451
452 try {
453 // ...
454 }
455 catch() {
456 // ...
457 }
Derek Jones129c1812011-10-05 17:15:44 -0500458
459**CORRECT**::
460
461 function foo($bar)
462 {
463 // ...
464 }
465
466 foreach ($arr as $key => $val)
467 {
468 // ...
469 }
470
471 if ($foo == $bar)
472 {
473 // ...
474 }
475 else
476 {
477 // ...
478 }
479
480 for ($i = 0; $i < 10; $i++)
481 {
482 for ($j = 0; $j < 10; $j++)
483 {
484 // ...
485 }
486 }
Timothy Warren82c83072012-01-26 19:02:05 -0500487
488 try
489 {
490 // ...
491 }
492 catch()
493 {
494 // ...
495 }
Derek Jones8ede1a22011-10-05 13:34:52 -0500496
497Bracket and Parenthetic Spacing
498===============================
499
500In general, parenthesis and brackets should not use any additional
501spaces. The exception is that a space should always follow PHP control
502structures that accept arguments with parenthesis (declare, do-while,
503elseif, for, foreach, if, switch, while), to help distinguish them from
504functions and increase readability.
505
Derek Jones129c1812011-10-05 17:15:44 -0500506**INCORRECT**::
Derek Jones8ede1a22011-10-05 13:34:52 -0500507
Derek Jones129c1812011-10-05 17:15:44 -0500508 $arr[ $foo ] = 'foo';
509
510**CORRECT**::
511
512 $arr[$foo] = 'foo'; // no spaces around array keys
513
514**INCORRECT**::
515
516 function foo ( $bar )
517 {
518
519 }
520
521**CORRECT**::
522
523 function foo($bar) // no spaces around parenthesis in function declarations
524 {
525
526 }
527
528**INCORRECT**::
529
530 foreach( $query->result() as $row )
531
532**CORRECT**::
533
534 foreach ($query->result() as $row) // single space following PHP control structures, but not in interior parenthesis
Derek Jones8ede1a22011-10-05 13:34:52 -0500535
536Localized Text
537==============
538
539Any text that is output in the control panel should use language
540variables in your lang file to allow localization.
541
Derek Jones129c1812011-10-05 17:15:44 -0500542**INCORRECT**::
Derek Jones8ede1a22011-10-05 13:34:52 -0500543
Derek Jones129c1812011-10-05 17:15:44 -0500544 return "Invalid Selection";
545
546**CORRECT**::
547
548 return $this->lang->line('invalid_selection');
Derek Jones8ede1a22011-10-05 13:34:52 -0500549
550Private Methods and Variables
551=============================
552
553Methods and variables that are only accessed internally by your class,
554such as utility and helper functions that your public methods use for
555code abstraction, should be prefixed with an underscore.
556
557::
558
Andrey Andreev16a704c2012-11-09 17:25:00 +0200559 public function convert_text()
560 private function _convert_text()
Derek Jones8ede1a22011-10-05 13:34:52 -0500561
562PHP Errors
563==========
564
565Code must run error free and not rely on warnings and notices to be
566hidden to meet this requirement. For instance, never access a variable
Andrey Andreev16a704c2012-11-09 17:25:00 +0200567that you did not set yourself (such as ``$_POST`` array keys) without first
568checking to see that it ``isset()``.
Derek Jones8ede1a22011-10-05 13:34:52 -0500569
570Make sure that while developing your add-on, error reporting is enabled
571for ALL users, and that display_errors is enabled in the PHP
572environment. You can check this setting with::
573
Derek Jones129c1812011-10-05 17:15:44 -0500574 if (ini_get('display_errors') == 1)
575 {
576 exit "Enabled";
577 }
Derek Jones8ede1a22011-10-05 13:34:52 -0500578
Andrey Andreev16a704c2012-11-09 17:25:00 +0200579On some servers where *display_errors* is disabled, and you do not have
Derek Jones8ede1a22011-10-05 13:34:52 -0500580the ability to change this in the php.ini, you can often enable it with::
581
582 ini_set('display_errors', 1);
583
Andrey Andreev16a704c2012-11-09 17:25:00 +0200584.. note:: Setting the `display_errors
585 <http://php.net/manual/en/ref.errorfunc.php#ini.display-errors>`_
586 setting with ``ini_set()`` at runtime is not identical to having
587 it enabled in the PHP environment. Namely, it will not have any
588 effect if the script has fatal errors.
Derek Jones8ede1a22011-10-05 13:34:52 -0500589
590Short Open Tags
591===============
592
593Always use full PHP opening tags, in case a server does not have
Andrey Andreev16a704c2012-11-09 17:25:00 +0200594*short_open_tag* enabled.
Derek Jones8ede1a22011-10-05 13:34:52 -0500595
Derek Jones129c1812011-10-05 17:15:44 -0500596**INCORRECT**::
Derek Jones8ede1a22011-10-05 13:34:52 -0500597
Derek Jones129c1812011-10-05 17:15:44 -0500598 <? echo $foo; ?>
599
600 <?=$foo?>
601
602**CORRECT**::
603
604 <?php echo $foo; ?>
Derek Jones8ede1a22011-10-05 13:34:52 -0500605
Andrey Andreev16a704c2012-11-09 17:25:00 +0200606.. note:: PHP 5.4 will always have the **<?=** tag available.
607
Derek Jones8ede1a22011-10-05 13:34:52 -0500608One Statement Per Line
609======================
610
611Never combine statements on one line.
612
Derek Jones129c1812011-10-05 17:15:44 -0500613**INCORRECT**::
Derek Jones8ede1a22011-10-05 13:34:52 -0500614
Derek Jones129c1812011-10-05 17:15:44 -0500615 $foo = 'this'; $bar = 'that'; $bat = str_replace($foo, $bar, $bag);
616
617**CORRECT**::
618
619 $foo = 'this';
620 $bar = 'that';
621 $bat = str_replace($foo, $bar, $bag);
Derek Jones8ede1a22011-10-05 13:34:52 -0500622
623Strings
624=======
625
626Always use single quoted strings unless you need variables parsed, and
627in cases where you do need variables parsed, use braces to prevent
628greedy token parsing. You may also use double-quoted strings if the
629string contains single quotes, so you do not have to use escape
630characters.
631
Derek Jones129c1812011-10-05 17:15:44 -0500632**INCORRECT**::
Derek Jones8ede1a22011-10-05 13:34:52 -0500633
Derek Jones129c1812011-10-05 17:15:44 -0500634 "My String" // no variable parsing, so no use for double quotes
635 "My string $foo" // needs braces
636 'SELECT foo FROM bar WHERE baz = \'bag\'' // ugly
637
638**CORRECT**::
639
640 'My String'
641 "My string {$foo}"
642 "SELECT foo FROM bar WHERE baz = 'bag'"
Derek Jones8ede1a22011-10-05 13:34:52 -0500643
644SQL Queries
645===========
646
Andrey Andreev16a704c2012-11-09 17:25:00 +0200647SQL keywords are always capitalized: SELECT, INSERT, UPDATE, WHERE,
Derek Jones8ede1a22011-10-05 13:34:52 -0500648AS, JOIN, ON, IN, etc.
649
650Break up long queries into multiple lines for legibility, preferably
651breaking for each clause.
652
Derek Jones129c1812011-10-05 17:15:44 -0500653**INCORRECT**::
Derek Jones8ede1a22011-10-05 13:34:52 -0500654
Derek Jones129c1812011-10-05 17:15:44 -0500655 // keywords are lowercase and query is too long for
656 // a single line (... indicates continuation of line)
657 $query = $this->db->query("select foo, bar, baz, foofoo, foobar as raboof, foobaz from exp_pre_email_addresses
658 ...where foo != 'oof' and baz != 'zab' order by foobaz limit 5, 100");
659
660**CORRECT**::
661
662 $query = $this->db->query("SELECT foo, bar, baz, foofoo, foobar AS raboof, foobaz
663 FROM exp_pre_email_addresses
664 WHERE foo != 'oof'
665 AND baz != 'zab'
666 ORDER BY foobaz
667 LIMIT 5, 100");
Derek Jones8ede1a22011-10-05 13:34:52 -0500668
669Default Function Arguments
670==========================
671
672Whenever appropriate, provide function argument defaults, which helps
673prevent PHP errors with mistaken calls and provides common fallback
674values which can save a few lines of code. Example::
675
Andrey Andreev16a704c2012-11-09 17:25:00 +0200676 function foo($bar = '', $baz = FALSE)