PHP Programming 1 PHP Programming
Total Page:16
File Type:pdf, Size:1020Kb
PHP Programming 1 PHP Programming PHP is a scripting language designed to fill the gap between SSI (Server Side Includes) and Perl, intended largely for the web environment. PHP has gained quite a following in recent times, and it is one of the forerunners in the Open Source software movement. Its popularity derives from its C-like syntax, and its simplicity. PHP is currently divided into two major versions: PHP 4 and PHP 5, although PHP 4 is deprecated and is no longer developed or supplied with critical bug fixes. PHP 6 is currently under development. If you've ever been to a website that needs you to login, you've probably encountered a server-side scripting language. Due to its market saturation, this means you've probably come across PHP. PHP was designed by Rasmus Lerdorf to display his resume online and to collect data from his visitors. Basically, PHP allows a static webpage to become dynamic. "PHP" is an acronym that stands for "PHP: Hypertext Preprocessor". The word "Preprocessor" means that PHP makes changes before the HTML page is created. This enables developers to create powerful applications which can publish a blog, remotely control hardware, or run a powerful website such as Wikipedia or Wikibooks. Of course, to accomplish something such as this, you need a database application such as MySQL. Before you embark on the wonderful journey of Server Side Processing, it is recommended that you have some basic understanding of the HyperText Markup Language. PHP is also being used to build GUI-driven applications; PHP-GTK is used to build graphical user interfaces. Setup and Installation • Installation on Windows • Easy Windows Setup Instructions • Installation on Linux • Installation on Mac OS X • Uses of PHP Note: Before contributing, check out the discussion page. How to write your examples. Learning the Language The Basics This section is about things that are important for any type of PHP development. Useful for a PHP programmer of any level. 1. Beginning with "Hello World!" 2. Nuts and Bolts 3. Commenting and Style 4. Arrays 5. Control structures 1. The if Structure PHP Programming 2 2. The switch Structure 3. The while Loop 4. The do while Loop 5. The for Loop 6. The foreach Loop 6. Functions 7. Files 8. Mailing 9. Cookies 10. Sessions 11. Databases 1. MySQL 2. PostgreSQL 3. PHP Data Objects 12. Integration Methods (HTML Forms, etc.) Advanced PHP Advanced PHP includes high level programming and PHP techniques designed to make PHP even more useful and powerful. Data Structures 1. Data Structures Object Oriented Programming (OOP) 1. Classes 2. Special Methods 3. Class Extensions (Inheritance) 4. The SSH Class Templating 1. Why Templating 2. Templates 3. Caching 4. SMARTY templating system 5. PRADO Component Framework 6. Flat Frog templating system 7. XSL PHP Programming 3 Libraries PHP PEAR Frameworks • CakePHP [1] • CodeIgniter [2] • Kohana [3] • Nette [4] • Qcodo [5] • Solar [6] • Symfony [7] • Zend Framework [8] • Yii [9] • Drupal [10] • Silverstripe [11] Security 1. Configuration: Register Globals 2. SQL Injection Attacks 3. Cross Site Scripting Attacks 4. Building a secure user login system See also the section on avoiding session fixation in the Sessions chapter. Command-Line Interface (CLI) 1. PHP CLI 2. PHP-GTK 3. Daemonization Appendices • Code Snippets • Coding Standards • Alternative Hungarian Notation • Editors • Resources • Contributors PHP Programming 4 References [1] http:/ / www. cakephp. org/ [2] http:/ / codeigniter. com/ [3] http:/ / kohanaphp. com/ [4] http:/ / nette. org/ [5] http:/ / www. qcodo. com/ [6] http:/ / www. solarphp. com/ [7] http:/ / www. symfony-project. org/ [8] http:/ / framework. zend. com/ [9] http:/ / www. yiiframework. com/ [10] http:/ / www. drupal. org/ [11] http:/ / www. silverstripe. com/ Article Sources and Contributors 5 Article Sources and Contributors PHP Programming Source: http://en.wikibooks.org/w/index.php?oldid=2264876 Contributors: "ramu" Ramakrishna Reddy, 2501, Aaronhall, AdRiley, Adorton, Adrignola, Adz, Ahc, Ahy1, Alerante, AlexeySmirnov, Amitverma, Aquinas, Arlen22, Ash211, Banzaimonkey, Bathilda1905, Bertbeck, Bolo, Bregovic, Bumppo, CWii, Charles Iliya Krempeaux, Chesemonkyloma, Da404lewzer, Dallas1278, Darklama, Derbeth, Deth4uall, DrQuincy, Dreftymac, Dvyjones, Dwclifton, Dwellings, Ed Poor, EdoDodo, Ekke, Fyorl, Geocachernemesis, Halavais, Herbythyme, Hyad, IBB, Ibex, Immortalgeek, JackPotte, Jad, Jamesbooker, Jatkins, JenVan, Jeshii, Jguk, Jomegat, Jshadias, Jtankers, Kalendos, Kander, Kaspars b, Kayau, Kenrick95, Kgrsajid, King elessar, Koos Jol, Krischik, Liuchangjohn, Lokeshwaran, Loquetudigas, ManuelGR, Masonbarge, Mattisse, Maxim K, Mga, Mike.lifeguard, Mkn, Monkeymatt, Mortense, N313t3, NipplesMeCool, Noah, Noldoaran, Nsoyeblcyha, Olajideolaolorun, Omegatron, Panic2k4, Peterw, Psoup, RalfE, Rdnk, Reach Out to the Truth, Red4tribe, Remi0o, Rocket000, Samwilson, Santosh Maharjan, Sigma 7, Sik0fewl, Sparky2002b, Spoom, Stevecody, Swift, Tim Peterson, Timgrin, Trince, Tslag, Unknown W. Brackets, Webaware, Wheat, Whiteknight, Wjgilmore, Wm, Wykis, Xianrenb, anonymous edits הדס, YMS, ZeiP, Zeus, Zodlicious, 265 Image Sources, Licenses and Contributors Image:PHPWikibookCover.png Source: http://en.wikibooks.org/w/index.php?title=File:PHPWikibookCover.png License: GNU General Public License Contributors: Original uploader was Banzaimonkey at en.wikibooks License Creative Commons Attribution-Share Alike 3.0 Unported //creativecommons.org/licenses/by-sa/3.0/.