0061 Course PHP Programming Language
0061 Course PHP Programming Language
by ebookvala.blogspot.com
INDEX
What is PHP?.................................................................................................................3
Installation on Linux.................................................................................................... 4
Installation on Windows...............................................................................................5
Installation on Mac OS X.............................................................................................6
Basics..............................................................................................................................12
Arrays .............................................................................................................................20
Functions ........................................................................................................................40
Files ................................................................................................................................47
.
Mailing ............................................................................................................................56
Cookies ..........................................................................................................................58
Sessions ........................................................................................................................60
Databases .....................................................................................................................63
MySQL ...........................................................................................................................63
PostgreSQL ....................................................................................................................66
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, its speed 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.
Since PHP is a server-side technology, you should naturally expect to invest some time in
setting up a server environment for production, development or learning. To be frank, PHP
is quite easy to set up compared to other monsters like J2EE. Nevertheless, the
procedures are complicated by the various combinations of different versions of web
server, PHP and database (most often MySQL). Below I will introduce the steps needed to
set up a working PHP environment with MySQL database.
Linux
If your desktop runs on Linux, chances are that Apache, PHP, and MySQL are already
installed for you. This wildly popular configuration is commonly referred to as LAMP, i.e.
Linux Apache MySQL PHP, or P, the latter 'P', can also refer to Perl another major player in
the opensource web service arena. If some components are not installed, you will likely
have to manually install the following packages:
Apache or Lighttpd
PHP
MySQL or Postgres
The PHP integration plugin for the database.
On Debian or its derivatives, Ubuntu included[1], you can use the corresponding
commands:
apt-get install php5
## Server
#### If you wish to use Apache
apt-get install apache2
## -or-
#### If you wish to use Lighttpd
apt-get install lighttpd
## Database
#### If you wish to use Postgres
apt-get install postgres-server postgres-client php5-pg
## -or-
#### If you wish to use Mysql
apt-get install mysql-server mysql-client php5-mysql
^ If you chose to use Ubuntu with Apache and MySQL you might wish to utilize the Ubuntu
community site for such a configuration ubuntu lamp wiki.
Gentoo
For Gentoo Linux users, the gentoo-wiki has this HowTo available: Apache2 with PHP and
MySQL.
RPM-based
The exact procedures depend on your Linux distribution. On a Fedora system, the
commands are typically as follows:
yum install httpd
yum install php
yum install mysql
yum install php-mysql
It's impossible to cover all the variants here, so consult your Linux distribution's manual for
more details, or grab a friend to do it for you.
One sure-fire way of getting PHP up and running on your *nix system is to compile it from
source. This isn't as hard as it may sound and there are good instructions available in the
PHP manual.
Windows
Contrary to what some people may think, PHP on Windows is a very popular option. On a
Windows platform, you have the option to use either the open source Apache web server,
or the native Internet Information Services (IIS) server from Microsoft, which can be
installed from your Windows CD. When you have one of these servers installed, you can
download and install the appropriate PHP Windows binaries distributions from PHP
download page. The installer version requires less user-interaction.
For increased performance you will want to use FastCGI. There is a wikibook that will
assist you on Setting up IIS with FastCGI.
Databases
Click here to download full PDF material