528Part IIIAdvanced Features and TechniquesFormatting functions and function (Web hosting top)
528Part IIIAdvanced Features and TechniquesFormatting functions and function callsMuch of PHP is concerned with defining functions, then making calls to them; and obviouslycode libraries like PEAR will be almost all functions. Properly formatting your functions canmake it more obvious what s going on and can therefore make debugging and maintenanceeasier. The PEAR style rules mandate that functions be defined with both their beginning and endingbraces flush with the left margin, like this: function myFunction() { // Function code goes here. } This makes function definitions (which use braces) stand out from conditional blocks (whichalso use braces). Furthermore, the standards require that code within the function be indented. Everything is indented at least four spaces; some segments may be indented further: function myFunction() { doSomething(); if ($is) { doSomethingMore(); } } If your function takes arguments, be sure to order them so that arguments with default valuesgo at the end of the list, like this: function myFunction($a, $b, $c= Default ) { doSomething(); if ($is) { doSomethingMore(); } } Also note that there should be no spaces between the name of the function and the parenthe- ses containing arguments. Again, this helps visually distinguish functions (which use paren- theses) from expressions (which also use parentheses). It is important that functions return something. The return value will either be a value thatresulted from the function s processing, or a Boolean value (true or false) to indicate successor failure. SummaryIn this chapter, you got an idea of the lengths to which the PHP community has gone to makeit easy for you to have and use the latest packages that extend the capabilities of the language. PEAR exists to facilitate the ongoing development and widespread distribution of handytoolkits.
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check Vision professional web hosting services