PHP Programming Language - Cultural View
PHP Programming Language - Cultural View PHP Programming Language - Cultural View
PHP syntax and semantics 170 ?> PHP supports quasi-anonymous functions through the create_function() function. These are not true anonymous functions because anonymous functions are nameless but functions can only be referenced by name in PHP. As of version 5.3, PHP also supports anonymous functions. [12] Function calls may be made via variables, where the value of a variable contains the name of the function to call. This is illustrated in the following example: PHP does not support named parameters or parameter skipping. [13] Some core PHP developers have publicly expressed disappointment with this decision. [13] . Others have suggested workarounds for this limitation. [14] Objects Basic object-oriented programming functionality was added in PHP 3. [15] Object handling was completely rewritten for PHP 5, expanding the feature set and enhancing performance. [16] In previous versions of PHP, objects were handled like primitive types. [16] The drawback of this method was that the whole object was copied when a variable was assigned or passed as a parameter to a method. In the new approach, objects are referenced by handle, and not by value. PHP 5 introduced private and protected member variables and methods, along with abstract classes and final classes as well as abstract methods and final methods. It also introduced a standard way of declaring constructors and destructors, similar to that of other object-oriented languages such as C++, and a standard exception handling model. Furthermore PHP 5 added Interfaces and allows for multiple Interfaces to be implemented. There are special interfaces that allow objects to interact with the runtime system. Objects implementing ArrayAccess can be used with array syntax and objects implementing Iterator or IteratorAggregate can be used with the foreach language construct. The static method and class variable features in Zend Engine 2 do not work the way some would expect. There is no virtual table feature in the engine, so static variables are bound with a name instead of a reference at compile time. [17] This example shows how to define a class, foo, that inherits from class bar. The function mystaticfunc is a public static function that can be called with foo::mystaticfunc();. class foo extends bar { function construct()
PHP syntax and semantics 171 } { $doo = "wah dee dee"; } public static function mystaticfunc() { $dee = "dee dee dum"; } If the developer creates a copy of an object using the reserved word clone, the Zend engine will check if a clone() method has been defined or not. If not, it will call a default clone() which will copy the object's properties. If a clone() method is defined, then it will be responsible for setting the necessary properties in the created object. For convenience, the engine will supply a function that imports the properties of the source object, so that the programmer can start with a by-value replica of the source object and only override properties that need to be changed. [18] References [1] Bray, Tim; et al (26 November 2008). "Processing Instructions" (http://www.w3.org/TR/2008/REC-xml-20081126/#sec-pi). Extensible Markup Language (XML) 1.0 (Fifth Edition). W3C. . Retrieved 2009-06-18. [2] "PHP: Basic syntax" (http://www.php.net/manual/en/language.basic-syntax.php). The PHP Group. . Retrieved 2008-02-22. [3] "Your first PHP-enabled page" (http://ca3.php.net/manual/en/tutorial.firstpage.php). The PHP Group. . Retrieved 2008-02-25. [4] "Variables" (http://www.php.net/manual/en/language.variables.php). The PHP Group. . Retrieved 2008-03-16. [5] "Instruction separation" (http://www.php.net/basic-syntax.instruction-separation). The PHP Group. . Retrieved 2008-03-16. [6] "Comments" (http://ca3.php.net/manual/en/language.basic-syntax.comments.php). The PHP Group. . Retrieved 2008-03-16. [7] "print" (http://www.php.net/print). The PHP Group. . Retrieved 2008-03-16. [8] "Hello World" (http://php.codenewbie.com/articles/php/1485/Hello_World-Page_1.html). Code Newbie. . Retrieved 2008-02-25. [9] "Colon Syntax in PHP" (http://www.kwista.com/programming/colon-syntax-in-php/). Kwista, LLC.. . Retrieved 2010-04-19. [10] "Alternative syntax for control structures" (http://php.net/manual/en/control-structures.alternative-syntax.php). The PHP Group. . Retrieved 2010-04-16. [11] "Types" (http://www.php.net/manual/en/language.types.php). The PHP Group. . Retrieved 2008-03-16. [12] "Functions" (http://www.php.net/manual/en/language.functions.php). The PHP Group. . Retrieved 2008-03-16. [13] "PHP 6 Dropped Items" (http://wiki.php.net/todo/backlog#dropped_items). The PHP Group. . Retrieved 2009-01-09. [14] "PHP Skipped and Named Parameters" (http://www.seoegghead.com/software/php-parameter-skipping-and-named-parameters.seo). SEO Egghead Inc.. . Retrieved 2009-01-09. [15] "History of PHP and related projects" (http://www.php.net/history). The PHP Group. . Retrieved 2008-02-25. [16] "PHP 5 Object References" (http://mjtsai.com/blog/2004/07/15/php-5-object-references/). mjtsai. . Retrieved 2008-03-16. [17] "Classes and Objects (PHP 5)" (http://ca3.php.net/zend-engine-2.php). The PHP Group. . Retrieved 2008-03-16. [18] "Object cloning" (http://ca3.php.net/language.oop5.cloning). The PHP Group. . Retrieved 2008-03-16.
- Page 125 and 126: Mambo (software) 119 [19] "NYS Depa
- Page 127 and 128: Merlintalk 121 • 2008: Released m
- Page 129 and 130: MetaBB 123 References [1] http://fo
- Page 131 and 132: Midgard (software) 125 Midgard (sof
- Page 133 and 134: Midgard (software) 127 See also •
- Page 135 and 136: Midgard Lite 129 Midgard Lite Midga
- Page 137 and 138: MindTouch Deki 131 History MindTouc
- Page 139 and 140: MindTouch Deki 133 Users of the Com
- Page 141 and 142: Moodle 135 Moodle Moodle course scr
- Page 143 and 144: Moodle 137 show, it has been cited
- Page 145 and 146: Moodle 139 See also • Learning ma
- Page 147 and 148: MyBB 141 MyBB A default installatio
- Page 149 and 150: MyBB 143 free software released und
- Page 151 and 152: NETSOFTWARE 145 Structure of compan
- Page 153 and 154: User:Nichescript/Affiliate Niche Sr
- Page 155 and 156: Ning (website) 149 Feature modifica
- Page 157 and 158: Ning (website) 151 [11] http://blog
- Page 159 and 160: NolaPro 153 In May 2005, NolaPro wa
- Page 161 and 162: ocPortal 155 ocPortal Developer(s)
- Page 163 and 164: ocPortal 157 Version history • Ma
- Page 165 and 166: Open Realty 159 References [1] Open
- Page 167 and 168: Opus (content management system) 16
- Page 169 and 170: osCommerce 163 osCommerce Developer
- Page 171 and 172: osCommerce 165 Branches Distributed
- Page 173 and 174: PEAR 167 External links • The PEA
- Page 175: PHP syntax and semantics 169 Colon
- Page 179 and 180: PHPClasses repository 173 PHPClasse
- Page 181 and 182: PHPDoc 175 markup for display forma
- Page 183 and 184: PHPDoc 177 The text that marks this
- Page 185 and 186: PHPDoc 179 @static Documents a stat
- Page 187 and 188: PHPEclipse 181 Further reading •
- Page 189 and 190: User:Papagel/EFront (eLearning soft
- Page 191 and 192: Phalanger (compiler) 185 Phalanger
- Page 193 and 194: pHAML 187 pHAML Developer(s) David
- Page 195 and 196: pHAML 189 Hello World Hello W
- Page 197 and 198: Phoca Gallery 191 References [1] ht
- Page 199 and 200: PHP 193 PHP Paradigm imperative, ob
- Page 201 and 202: PHP 195 Licensing PHP is free softw
- Page 203 and 204: PHP 197 Security The National Vulne
- Page 205 and 206: PHP 199 $adder = getAdder(8); echo
- Page 207 and 208: PHP 201 Speed optimization PHP sour
- Page 209 and 210: PHP 203 [18] "GoPHP5" (http://gophp
- Page 211 and 212: HipHop for PHP 205 HipHop for PHP D
- Page 213 and 214: PHP-GTK 207 PHP-GTK Developer(s) An
- Page 215 and 216: PHP-GTK 209 External links • Offi
- Page 217 and 218: PHP-Nuke 211 • News—Manages new
- Page 219 and 220: Php4delphi 213 Php4delphi Appeared
- Page 221 and 222: phpDocumentor 215 phpDocumentor Sta
- Page 223 and 224: PhpGedView 217 PhpGedView can be ex
- Page 225 and 226: phpLDAPadmin 219 phpLDAPadmin Origi
<strong>PHP</strong> syntax and semantics 170<br />
?><br />
<strong>PHP</strong> supports quasi-anonymous functions through the create_function() function. These are not true anonymous<br />
functions because anonymous functions are nameless but functions can only be referenced by name in <strong>PHP</strong>. As of<br />
version 5.3, <strong>PHP</strong> also supports anonymous functions. [12]<br />
Function calls may be made via variables, where the value of a variable contains the name of the function to call.<br />
This is illustrated in the following example:<br />
<br />
<strong>PHP</strong> does not support named parameters or parameter skipping. [13] Some core <strong>PHP</strong> developers have publicly<br />
expressed disappointment with this decision. [13] . Others have suggested workarounds for this limitation. [14]<br />
Objects<br />
Basic object-oriented programming functionality was added in <strong>PHP</strong> 3. [15] Object handling was completely rewritten<br />
for <strong>PHP</strong> 5, expanding the feature set and enhancing performance. [16] In previous versions of <strong>PHP</strong>, objects were<br />
handled like primitive types. [16] The drawback of this method was that the whole object was copied when a variable<br />
was assigned or passed as a parameter to a method. In the new approach, objects are referenced by handle, and not<br />
by value. <strong>PHP</strong> 5 introduced private and protected member variables and methods, along with abstract classes and<br />
final classes as well as abstract methods and final methods. It also introduced a standard way of declaring<br />
constructors and destructors, similar to that of other object-oriented languages such as C++, and a standard exception<br />
handling model. Furthermore <strong>PHP</strong> 5 added Interfaces and allows for multiple Interfaces to be implemented. There<br />
are special interfaces that allow objects to interact with the runtime system. Objects implementing ArrayAccess can<br />
be used with array syntax and objects implementing Iterator or IteratorAggregate can be used with the foreach<br />
language construct. The static method and class variable features in Zend Engine 2 do not work the way some would<br />
expect. There is no virtual table feature in the engine, so static variables are bound with a name instead of a reference<br />
at compile time. [17]<br />
This example shows how to define a class, foo, that inherits from class bar. The function mystaticfunc is a<br />
public static function that can be called with foo::mystaticfunc();.<br />
class foo extends bar<br />
{<br />
function construct()