PHP

From Christoph's Personal Wiki
Revision as of 01:44, 17 August 2007 by Christoph (Talk | contribs)

Jump to: navigation, search

PHP (PHP: Hypertext Preprocessor) is an open-source, reflective programming language. Originally designed as a high level scripting language for producing dynamic Web pages, PHP is used mainly in server-side application software.

Sandbox

Inconsistent arguments and return values

To illustrate this problem, below is a table of the functions that match a user defined thing:

                         replaces case                 gives   s/m/x offset
                 matches with     insens number arrays matches flags (-1=end)
ereg             ereg             no     all    no     array   no    0
ereg_replace     ereg    str      no     all    no     no      no    0
eregi            ereg             yes    all    no     array   no    0
eregi_replace    ereg    str      yes    all    no     no      no    0
mb_ereg          ereg[1]          no     all    no     array   no    0
mb_ereg_replace  ereg[1] str/expr no     all    no     no      yes   0
mb_eregi         ereg[1]          yes    all    no     array   no    0
mb_eregi_replace ereg[1] str      yes    all    no     no      no    0
preg_match       preg[2]          yes/no one    no     array   yes   0
preg_match_all   preg             yes/no all    no     array   yes   0
preg_replace     preg    str/expr yes/no n/all  yes    no      yes   0
str_replace      str     str      no     all    yes    number  no    0
str_ireplace     str     str      yes    all    yes    number  no    0
strstr, strchr   str/char         no     one    no     substr  no    0
stristr          str/char         yes    one    no     substr  no    0
strrchr          char             no     one    no     substr  no    -1
strpos           str/char         no     one    no     index   no    n
stripos          str/char         yes    one    no     index   no    n
strrpos          char[3]          no     one    no     index   no    n
strripos         str              yes    one    no     index   no    -1
mb_strpos        str[1]           no     one    no     index   no    n
mb_strrpos       str[1]           yes    one    no     index   no    -1

[1] Handles multi-byte characters; [2] PCRE regex: so-called "Perl compatible" regular expressions; [3] Also does strings in PHP 5

Note: The same problem exists for other function groups, not just for matching. Also note: In Perl, all the functionality provided by the functions in this table is available through a simple set of 4 operators.

External links