161 likes | 556 Views
What is PHP?. PHP (recursive acronym for "PHP: Hypertext Preprocessor") is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. What can PHP do?. Server-side Scripting:.
E N D
What is PHP? PHP (recursive acronym for "PHP: Hypertext Preprocessor") is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.
What can PHP do? Server-side Scripting: • This is the most traditional and main target field for PHP. You need three things to make this work: • The PHP parser (CGI or server module) • A web browser • A webserver with a connected PHP installation. • All these can run on your home machine if you are just experimenting with PHP programming.
What can PHP do? Command Line Scripting: You can make a PHP script to run it without any server or browser. You only need the PHP parser to use it this way. This type of usage is ideal for scripts regularly executed using cron (on *nix or Linux) or Task Scheduler (on Windows). These scripts can also be used for simple text processing tasks.
What can PHP do? Desktop Applications: Writing desktop applications. PHP is probably not the very best language to create a desktop application with a graphical user interface, but if you know PHP very well, and would like to use some advanced PHP features in your client-side applications you can also use PHP-GTK to write such programs. You also have the ability to write cross-platform applications this way.
Database Strength: Adabas D InterBase PostgreSQL dBase FrontBase SQLite Empress mSQL Solid FilePro (read-only) Direct MS-SQL Sybase Hyperwave MySQL Velocis IBM DB2 ODBC Unix dbm Informix Oracle (OCI7 and OCI8) Ingres Ovrimos
Ubiquitous Setups: • Most commonly used with Apache Web Server as module • Most commonly used with MySQL Database Server • Most commonly used on the Linux platform Additional Common Setups: • Growing number of installations on Windows machines • Local development setups are popular
Simple Web Page Example:helloworld.php <html> <head> <title>Example</title> </head> <body><?phpecho ‘Hello, world!’; ?> </body></html>
The Guts Variables: - variables are given a value at declaration but not a type $foo = 0; - always preceded by the dollar sign: $ - vars can be converted to common specific types (int, variant, etc.) - typical scope rules apply, but global command may be used for public or global variables
The Guts Functions: - typically declared in “global” files that are included by all your other website pages -> keep them in one place - optionally with arguments and can return values <?php function fooFunction($arg1, $arg2 = '') { if (condition) { statement; } return $val; } ?>
The Guts Classes: - more forgiving than in C++, VB, C# or similar approaches - excellent way to encapsulate and control code <?php class clsFoo { var $my_color = ‘green’; function clsFoo ($arg1) { $this->my_color = $arg1; } } ?>
Where to Start? • www.php.net • www.phpmyadmin.net (best free MySQL management tool) • www.mysql.org (.com) • www.apache.org (version 1.3.x recommended for a local install) • www.jtlnet.com (cheap php/mysql hosting – tons out there) • www.phpbuilder.com (coding resource) • www.zend.com (Zend Studio 5.x – Visual Studio-type IDE)