[ Index ] |
|
Code source de Horde 3.1.3 |
1 ======================== 2 Horde Coding Standards 3 ======================== 4 5 :Last update: $Date: 2006/03/17 06:18:07 $ 6 :Revision: $Revision: 1.84.10.15 $ 7 :Authors: Jon Parise, Chuck Hagenbuch 8 :Contact: dev@lists.horde.org 9 10 .. contents:: Contents 11 .. section-numbering:: 12 13 Indenting 14 ========= 15 16 Use an indent of 4 spaces, with no tabs. 17 18 19 Control Structures 20 ================== 21 22 These include ``if``, ``for``, ``while``, ``switch``, etc. Here is an example 23 ``if`` statement, since it is the most complicated of them:: 24 25 if ((condition1) || (condition2)) { 26 action1; 27 } elseif ((condition3) && (condition4)) { 28 action2; 29 } else { 30 defaultaction; 31 } 32 33 Multi-line if conditions are braced this way:: 34 35 if ((condition1) || (condition2) || (condition3) || 36 (condition4)) { 37 action1; 38 } 39 40 Control statements should have one space between the control keyword and 41 opening parenthesis, to distinguish them from function calls. 42 43 Do not omit the curly braces under any circumstance. In the case of a large 44 number of short tests and actions, the following is acceptable:: 45 46 if (condition) { action; } 47 if (condition 2) { action 2; } 48 ... 49 50 For switch statements:: 51 52 switch (condition) { 53 case 1: 54 action1; 55 break; 56 57 case 2: 58 action2; 59 break; 60 61 default: 62 defaultaction; 63 break; 64 } 65 66 67 Function Calls 68 ============== 69 70 Functions should be called with no spaces between the function name, the 71 opening parenthesis, and the first parameter; spaces between commas and each 72 parameter, and no space between the last parameter, the closing parenthesis, 73 and the semicolon. Here's an example:: 74 75 $var = foo($bar, $baz, $quux); 76 77 As displayed above, there should be one space on either side of an equals sign 78 used to assign the return value of a function to a variable. In the case of a 79 block of related assignments, more space may be inserted to promote 80 readability:: 81 82 $short = foo($bar); 83 $long_variable = foo($baz); 84 85 86 Function Definitions 87 ==================== 88 89 Function declarations follow the "BSD/Allman" convention:: 90 91 function fooFunction($arg1, $arg2 = '') 92 { 93 if (condition) { 94 statement; 95 } 96 return $val; 97 } 98 99 Arguments with default values go at the end of the argument list. Always 100 attempt to return a meaningful value from a function if one is appropriate. 101 102 Functions used only in the current script/class (e.g. private member methods) 103 should begin with a ``_`` character (e.g. ``_exampleLibrary``). This helps 104 distinguish these private function calls from other, public function calls. 105 106 107 Class Definitions 108 ================= 109 110 Class definitions follow the "K&R/Kernel" convention:: 111 112 class Some_Class { 113 114 var $_variable; 115 116 function fooFunction() 117 { 118 statement; 119 } 120 121 } 122 123 Note the blank lines at the beginning and end of the class definition. 124 125 126 Naming Libraries 127 ================ 128 129 Libraries (any file located in the ``lib/`` directory of the application) 130 should be named with capital letters at the beginning of each word. Use 131 studlycaps for naming; a session cache class would be stored in 132 ``lib/SessionCache.php``. 133 134 If the library/class is extended, the extending files should be stored in a 135 directory under ``lib/`` with the same name as the original library. 136 Subclasses follow the exact same naming requirements, except that if the 137 subclass is instantiated by a factory method, it should be all lowercase. 138 139 Example 140 ------- 141 142 The "Example Library" library should be saved as ``lib/ExampleLibrary.php``. 143 Any file extending the library/class should be stored in the directory 144 ``lib/ExampleLibrary/``. 145 146 147 Comments 148 ======== 149 150 Inline documentation for classes should follow the `Javadoc convention`_. 151 152 .. _Javadoc convention: http://java.sun.com/products/jdk/javadoc/writingdoccomments/index.html 153 154 Quick example for private variable definition for Horde:: 155 156 /** 157 * Variable description. 158 * 159 * @var datatype 160 */ 161 162 Quick example function definition for Horde:: 163 164 /** 165 * The description of the function goes here. 166 * 167 * @access [private | protected] 168 * [Don't bother with "public" since it is the default if not specified.] 169 * 170 * @param datatype $variablename Description of variable. 171 * @param datatype $variable2name Description of variable2. 172 * ... 173 * [Insert 2 spaces after the longest $variable definition, and then line 174 * up all descriptions with this description] 175 * 176 * @return datatype Description of return value. 177 * [Once again, insert 2 spaces after the datatype, and line up all 178 * subsequent lines, if any, with this character.] 179 * 180 * @abstract [Only if necessary] 181 * 182 * @since Horde x.x [Only if necessary - use if function is added to the 183 * current release versions to indicate that the function has not been 184 * available in previous versions.] 185 */ 186 187 188 Including Code 189 ============== 190 191 If you are including a class, function library, or anything else which would 192 cause a parse error if included twice, always use `include_once`_. This will 193 ensure that no matter how many factory methods we use or how much dynamic 194 inclusion we do, the library will only be included once. 195 196 If you are including a static filename, such as a conf file or a template that 197 is *always* used, use `require`_. 198 199 If you are dynamically including a filename, or want the code to only be used 200 conditionally (an optional template), use `include`_. 201 202 .. _include_once: http://www.php.net/manual/en/function.include-once.php 203 .. _require: http://www.php.net/manual/en/function.require.php 204 .. _include: http://www.php.net/manual/en/function.include.php 205 206 207 PHP Code Tags 208 ============= 209 210 Always use ``<?php ?>`` to delimit PHP code, not the ``<? ?>`` shorthand. 211 This is required for PEAR compliance and is also the most portable way to 212 include PHP code on differing operating systems and setups. 213 214 In templates, make sure to use this as well (``<?php echo $varname ?>``), as 215 the shortcut version (``<?= $var ?>``) does not work with `short_open_tag`_ 216 turned off. 217 218 .. _short_open_tag: http://www.php.net/manual/en/configuration.directives.php#ini.short-open-tag 219 220 221 Header Comment Blocks 222 ===================== 223 224 All source code files in the Horde distribution should contain the following 225 comment block as the header: 226 227 Example for `LGPL`_'ed Horde code:: 228 229 /** 230 * The Horde_Foo:: class provides an API for various foo 231 * techniques that can be used by Horde applications. 232 * 233 * $Horde 234 * 235 * Copyright 1999-2001 Original Author <author@example.com> 236 * Copyright 2001 Your Name <you@example.com> 237 * 238 * See the enclosed file COPYING for license information (LGPL). If you 239 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. 240 * 241 * @author Original Author <author@example.com> 242 * @author Your Name <you@example.com> 243 * @since Horde 3.0 244 * @package Horde_Package 245 */ 246 247 .. _LGPL: http://www.opensource.org/licenses/lgpl-license.php 248 249 Example for `GPL`_'ed application code:: 250 251 /** 252 * The App_Bar:: class contains all functions related to handling 253 * bars in App. 254 * 255 * $Horde 256 * 257 * Copyright 1999-2001 Original Author <author@example.com> 258 * Copyright 2001 Your Name <you@example.com> 259 * 260 * See the enclosed file COPYING for license information (GPL). If you 261 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. 262 * 263 * @author Original Author <author@example.com> 264 * @author Your Name <you@example.com> 265 * @since App 1.0 266 * @package app 267 */ 268 269 270 .. _GPL: http://www.opensource.org/licenses/gpl-license.php 271 272 There's no hard rule to determine when a new code contributer should be added 273 to the list of authors for a given source file. In general, their changes 274 should fall into the "substantial" category (meaning somewhere around 10% to 275 20% of code changes). Exceptions could be made for rewriting functions or 276 contributing new logic. 277 278 Simple code reorganization or bug fixes would not justify the addition of a 279 new individual to the list of authors. 280 281 282 CVS Tags 283 ======== 284 285 Include the <dollar>Horde: <dollar> CVS vendor tag in each file. As each file 286 is edited, add this tag if it's not yet present (or replace existing forms 287 such as <dollar>Id<dollar>, "Last Modified:", etc.). 288 289 EXCEPTION: Don't include these in templates. 290 291 292 Example URLs 293 ============ 294 295 Use ``example.com`` for all example URLs, per `RFC 2606`_. 296 297 .. _RFC 2606: http://www.faqs.org/rfcs/rfc2606.html 298 299 300 php.ini settings 301 ================ 302 303 All Horde code should work with `register_globals`_ disabled. This means 304 using ``$_COOKIE``, ``$_SESSION``, ``$_SERVER`` and ``$_ENV`` to access all 305 cookie, session, server and environment data, respectively. 306 307 To retrieve posted data (in the global ``$_GET`` and ``$_POST`` variables), 308 you should normally use `Util::getFormData()`_ which will automatically run 309 `Util::dispelMagicQuotes()`_. This will ensure that all Horde code will work 310 regardless of the setting of `magic_quotes_gpc`_. The only time you should not 311 use `Util::getFormData()`_ is if you want to directly access a GET or POST 312 variable instead; in this case, you should use `Util::getGet()`_ or 313 `Util::getPost()`_ respectively. 314 315 All Horde code should work with `error_reporting`_ = E_ALL. Failure to do so 316 would result in ugly output, error logs getting filled with lots of warning 317 messages, or even downright broken scripts. 318 319 No Horde code should assume that '.' is in the include path. Always specify 320 './' in front of a filename when you are including a file in the same 321 directory. 322 323 .. _register_globals: http://www.php.net/manual/en/security.registerglobals.php 324 .. _magic_quotes_gpc: http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-gpc 325 .. _error_reporting: http://www.php.net/manual/en/ref.errorfunc.php#ini.error-reporting 326 .. _Util::getFormData(): http://dev.horde.org/api/framework/Horde_Util/Util.html#methodgetFormData 327 .. _Util::dispelMagicQuotes(): http://dev.horde.org/api/framework/Horde_Util/Util.html#methoddispelMagicQuotes 328 .. _Util::getGet(): http://dev.horde.org/api/framework/Horde_Util/Util.html#methodgetGet 329 .. _Util::getPost(): http://dev.horde.org/api/framework/Horde_Util/Util.html#methodgetPost 330 331 332 XHTML 1.0 Compliance 333 ==================== 334 335 All tag names and parameters must be lower case including javascript event 336 handlers:: 337 338 <font color="#FFFFFF">...</font> 339 <a href="http://example.com" onmouseover="status=''" onmouseout="status=''">...</a> 340 341 All tag parameters must be of a valid parameter="value" form (numeric values 342 must also be surrounded by quotes). For parameters that had no value in HTML, 343 the parameter name is the value. For example:: 344 345 <input type="checkbox" checked="checked"> 346 <select name="example"> 347 <option selected="selected" value="1">Example</option> 348 </select> 349 <td nowrap="nowrap">Example</td> 350 351 All tags must be properly closed. Tags where closing is forbidden must end 352 with a space and a slash:: 353 354 <br /> 355 <hr /> 356 <img src="example.gif" alt="Example" /> 357 <input type="submit" value="Example" /> 358 359 All form definitions must be on their own line and either fully defined within 360 a ``<td></td>`` pair or be outside table tags. Forms must also always have an 361 action parameter:: 362 363 <form method="post" action="http://example.com/example.cgi"> 364 <table> 365 <tr><td>example</td></tr> 366 </table> 367 </form> 368 369 <table> 370 <tr><td> 371 <form action="javascript:void(0)" onsubmit="return false;"> 372 </form> 373 </td></tr> 374 </table> 375 376 All JavaScript tags must have a valid type parameter:: 377 378 <script type="text/javascript"> 379 <!-- 380 ... 381 // --> 382 </script> 383 384 Nothing may appear after ``</html>``, therefore include any common footers 385 after all other output. 386 387 All images must have an ``alt`` attribute:: 388 389 <img src="example.gif" alt="<?php echo _("Example") ?>" /> 390 <?php echo Horde::img('example.gif', _("Example")) ?> (On the HEAD branch) 391 <?php echo Horde::img('example.gif', 'alt="' . _("Example") . '"') ?> (On the RELENG_2 branch) 392 393 Input fields of type "image" do not allow the border attribute and may render 394 with a border on some browsers. Use the following instead:: 395 396 <a href="" onclick="document.formname.submit(); return false;"><?php echo Horde::img("example.gif", _("Example")) ?></a> 397 398 399 Database Naming Conventions 400 =========================== 401 402 All database tables used by Horde resources and Horde applications need to 403 make sure that their table and field names work in all databases. Many 404 databases reserve words like 'uid', 'user', etc. for internal use, and forbid 405 words that are SQL keywords (select, where, etc.). Also, all names should be 406 lowercase, with underscores ('_') to separate words, to avoid case sensitivity 407 issues. 408 409 A good way to do this for field names is to make the field name 410 tablename_fieldname. 411 412 Other general guidelines: Table names should be plural (users); field names 413 should be singular (user_name). 414 415 416 Regular Expression Use 417 ====================== 418 419 Always use the `preg_`_ functions if possible instead of `ereg_`_ (and 420 `preg_split()`_ instead of `split()`_); they are included in PHP by default 421 and much more efficient and much faster than `ereg_`_. 422 423 **NEVER** use a regular expression to match or replace a static string. 424 `explode()`_ (in place of `split()`_), `str_replace()`_, `strpos()`_, or 425 `strtr()`_ do the job much more efficiently. 426 427 .. _preg_: http://www.php.net/manual/en/ref.pcre.php 428 .. _ereg_: http://www.php.net/manual/en/ref.regex.php 429 .. _preg_split(): http://www.php.net/manual/en/function.preg-split.php 430 .. _split(): http://www.php.net/manual/en/function.split.php 431 .. _explode(): http://www.php.net/manual/en/function.explode.php 432 .. _str_replace(): http://www.php.net/manual/en/function.str-replace.php 433 .. _strpos(): http://www.php.net/manual/en/function.strpos.php 434 .. _strtr(): http://www.php.net/manual/en/function.strtr.php 435 436 437 Parameter Passing 438 ================= 439 440 Objects should be passed by reference. Everything else, including arrays, 441 should be passed by value wherever semantically possible. 442 443 [Zend Engine 2: objects should also be passed by value] 444 445 This practice takes full advantage of reference counting. 446 447 .. Note:: The `ternary operator`_ automatically returns a copy of its 448 operands, so don't use it with objects, or if you are sure you want 449 to return an object copy. 450 451 .. _`ternary operator`: http://www.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary 452 453 454 Long Lines 455 ========== 456 457 Wrap lines at 80 characters, including comments, unless this severely impacts 458 the clarity of the code. Always wrap comments. 459 460 461 Line Breaks 462 =========== 463 464 Only use UNIX style of linebreak (``\n``), not Windows/DOS/Mac style 465 (``\r\n``). 466 467 Using vim, to convert from DOS style type:: 468 469 :set ff=unix 470 471 Using vi, to convert from DOS style type:: 472 473 :g/^M/s///g 474 475 (Note that the ``^M`` is a control character, and to reproduce it when you 476 type in the vi command you have to pad it first using the special ``^V`` 477 character.) 478 479 480 Private Variables 481 ================= 482 483 Variables used exclusively within a class should begin with a underscore ('_') 484 character. An example class variable definition: ``var $_variablename;`` 485 486 487 Array Definitions 488 ================= 489 490 When defining arrays, or nested arrays, use the following format, where 491 indentation is noted via the closing parenthesis characters:: 492 493 $arrayname['index'] = array( 494 'name1' => 'value1', 495 'name2' => array( 496 'subname1' => 'subvalue1', 497 'subname2' => 'subvalue2' 498 ) 499 ); 500 501 The only exception should be for empty or short arrays that fit on one line, 502 which may be written as:: 503 504 $arrayname['index'] = array(); 505 506 507 Internationalization (I18n) 508 =========================== 509 510 Mark all strings presented to the user as gettext strings by calling the 511 gettext shortcut function (``_()``):: 512 513 echo _("Hello world"); 514 515 Don't use the gettext functions for strings that will be written to a log file 516 or otherwise presented to the administrator. 517 518 The String:: class contains several string manipulation methods that are, as 519 opposed to their PHP equivalents, locale and charset safe. 520 521 Use String::convertCharset() if you need to convert between different 522 character set encodings (for example, between user input and a storage backend 523 or data from an external source and the user interface). You don't need to 524 care if the character sets are really different. 525 526 Use the String::lower() and String::upper() methods without a second 527 parameter if you need to perform a locale-independent string conversion. 528 That's the case for all strings that are further processed or interpreted by 529 code. Use these methods with the second parameter set to true for strings 530 that need to be converted correctly according to the current (or specified) 531 character set. 532 533 Use the other String:: equivalents of PHP string functions to manipulate 534 strings correctly according to the current (or specified) character set but 535 use the PHP functions for code/machine processed strings. 536 537 538 Error checking 539 ============== 540 541 Horde code should use `PEAR_Error`_ objects to return most error conditions 542 from library calls, and many times we will simply pass back a `PEAR_Error`_ 543 object generated by an underlying library (such as Mail or PEAR DB). 544 545 For these cases, use the following style of code block to check for success 546 after any call which could generate an error condition:: 547 548 $result = $something->call('may error'); 549 if (is_a($result, 'PEAR_Error')) { 550 // Handle error condition. 551 } else { 552 // Succeeded. 553 } 554 555 Note that `is_a()`_ checks for subclasses of the named class, as well, so if 556 the object you get back is really a `DB_Error`_ object, this will still catch 557 it (since `DB_Error`_ extends `PEAR_Error`_). 558 559 Calling PEAR::isError() results in the same behavior, but is_a() 560 accomplishes the same result with a single native PHP function call. 561 562 .. _PEAR_Error: http://pear.php.net/manual/en/core.pear.pear-error.php 563 .. _DB_Error: http://pear.php.net/manual/en/package.database.db.db-error.php 564 .. _is_a(): http://www.php.net/manual/en/function.is-a.php 565 566 567 Existence checking 568 ================== 569 570 Often you'll need to check whether or not a variable or property exists. 571 There are several cases here: 572 573 a. If you need to know if a variable exists at all and is not ``null``, use 574 `isset()`_:: 575 576 // Check to see if $param is defined. 577 if (isset($param)) { 578 // $param may be false, but it's there. 579 } 580 581 b. If you need to know if a variable exists AND has a non-empty value (not 582 ``null``, 0, ``false``, empty string or undefined), use !`empty()`_:: 583 584 // Make sure that $answer exists, is not an empty string, and is 585 // not 0: 586 if (!empty($answer)) { 587 // $answer has some non-false content. 588 } else { 589 // (bool)$answer would be false. 590 } 591 592 As pointed out in the comment of the else clause, `empty()`_ essentially does 593 the same check as `isset()`_ -- is this variable defined in the current scope? 594 -- and then, if it is, returns what the variable would evaluate to as a 595 boolean. This means that 0, while potentially valid input, is "empty" - so if 596 0 is valid data for your case, don't use !`empty()`_. 597 598 c. If you know you are working with a mixed variable then using just 599 `isset()`_ and `empty()`_ could cause unexpected results, for example if 600 testing for a key and the variable is actually a string:: 601 602 $foo = 'bar'; 603 if (isset($foo['somekey'])) { 604 // This will evaluate to TRUE! 605 } 606 607 If you know that there is a possibility of a mixed type variable the solution 608 in this case would be to add an `is_array()`_ check in the ``if()`` statement. 609 610 d. Use `array_key_exists()`_ when you want to check if an array key is defined 611 even if it has a value of ``null``:: 612 613 // Make sure we have a charset parameter. Value could also be null. 614 if (!array_key_exists('charset', $params)) { 615 Horde::fatal('Incomplete configuration.'); 616 } 617 618 Please note that `array_key_exists()`_ is a performance hit (25%-100%) and 619 should only be used when necessary. Instead try to use !`empty()`_ or 620 `isset()`_ instead. 621 622 .. _isset(): http://www.php.net/manual/en/function.isset.php 623 .. _empty(): http://www.php.net/manual/en/function.empty.php 624 .. _is_array(): http://www.php.net/manual/en/function.is-array.php 625 .. _array_key_exists(): http://www.php.net/manual/en/function.array-key-exists.php 626 627 628 Quotes 629 ====== 630 631 You should always use single quote (') characters around strings, except where 632 double quote (") characters are required. All literal strings should be in 633 single quotes. A comparison of single and double quote usage follows: 634 635 Single Quotes: 636 * Variables in the string are not parsed or expanded. 637 * New line symbols can be included as literal line ends (not recommended). 638 * To include a single quote character, escape it with a ``\`` (backslash) 639 character, as in: ``echo 'Here\'s an example';`` 640 * To specify a ``\`` (backslash) character, double it: ``echo 'c:\\temp';`` 641 642 Double Quotes: 643 * Parses and expands variables in the string. 644 * Uses advanced (`sprintf`_-style) escape sequences like ``\n``, ``\$``, 645 ``\t``, etc. 646 * Should be used in the gettext shortcut ``_("")`` format. 647 * Use with care, as many correct looking strings are really invalid. 648 649 The following are all incorrect:: 650 651 echo "Today is the $date['day'] of $date['month']" 652 $_SESSION[index] = $_SESSION["old_index"]; 653 654 .. _sprintf: http://www.php.net/sprintf 655 656 657 define() 658 ======== 659 660 Surprisingly enough, `define()`_ is a somewhat slow function in PHP (as of PHP 661 4.3.x) so excessive use is discouraged. 662 663 Using `define()`_ in classes should be OK - we will sacrifice a tiny bit of 664 speed for readability of code. `define()`_ should NOT be used for actionIDs - 665 use a plain old string instead. For anything else, use your best judgment. 666 667 Additionally, every constant should be prefixed with ``HORDE_``, its package 668 name, or the application name. 669 670 .. _define(): http://www.php.net/manual/en/function.define.php 671 672 673 Security Considerations 674 ======================= 675 676 The following are a non-exhaustive list of features/functions to take 677 special care with: 678 679 PHP Code Execution: 680 ------------------- 681 682 require, include, require_once, include_once - Carefully audit any 683 variables used in these functions, and check the source of any 684 constants as well. 685 686 eval - Obvious danger if user input is supplied to it in uncontrolled conditions. 687 688 preg_replace - The /e modifier causes the replacement string to be 689 evaluated as PHP code. 690 691 Command Execution: 692 ------------------ 693 694 exec - Executes a specified command and returns the last line of output. 695 696 passthru - Executes a specified command and writes the output to STDOUT. 697 698 `` (backticks) - Executes the specified command and returns all the 699 output in an array. 700 701 system - Like passthru() but doesn't handle binary data. 702 703 popen - Executes a specified command and connects its output or input 704 stream to a PHP file descriptor. 705 706 File Disclosure: 707 ---------------- 708 709 File functions which can be potentially used to open remote or 710 unintended files: fopen, readfile, file, file_get_contents. 711 712 713 Optimizations 714 ============= 715 716 The following optimizations should be used, if possible: 717 718 extension_loaded() 719 ------------------ 720 This appears to be an expensive PHP call. Use Util::extensionExists() 721 instead, which will cache the results of the call. 722 723 Concatenate strings 724 ------------------- 725 Building a string with concatenation (the "." operator) using 726 single-quoted strings and variables is faster than using an 727 interpolated string (a string inside double quotes with variables 728 inside the string itself). In addition, concatenation is easier to 729 read and audit for logic and security problems. 730 731 Pre-increment/decrement 732 ----------------------- 733 Because of the way compilers/interpreters work, post-incrementing 734 ($var++) requires storing both the original and new values of the 735 variable in memory because the old value may be used after the 736 operation in question is complete. By comparison, pre-incrementing 737 (++$var) almost never needs to store both values. It's a marginal 738 speedup but it's also simply changing the order of a few characters. 739 740 Loops 741 ----- 742 Make sure that you do not continue to define the same variable within a 743 loop. Instead, declare the variable a single time before the loop is run. 744 745 Array 746 ----- 747 Avoid frequent array accesses. If you use an array or an array member in a 748 loop, assign it to a variable first:: 749 750 $a = array('x' => 'y'); 751 $entries = array(...); 752 753 $length = count($entries); 754 $x = $a['x']; 755 for ($i = 0; $i < $length; ++$i) { 756 echo $x; 757 } 758 759 User defined functions 760 ---------------------- 761 User defined functions are more expensive than "regular" functions. Use them 762 only if they improve the code readability more then regular functions. 763 764 Disk I/O 765 -------- 766 Disk read and write operations are slow. If possible read and write files in 767 large chunks. According to PHP documentation, file_get_contents() is 768 potentially much faster than using fopen()/fread()/fclose(). 769 770 771 STDIN/STDOUT/STDERR 772 =================== 773 774 To access either STDIN, STDOUT, or STDERR, the following code should be used:: 775 776 while (!feof([STDIN|STDOUT|STDERR])) { 777 $line = fgets([STDIN|STDOUT|STDERR]); 778 // process $line here 779 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |