Introduction To PHP History of PHP
Introduction To PHP History of PHP
Introduction To PHP History of PHP
History of PHP:
The original release of PHP was designed and created by Rasmus Lerdorf back in the middle
of the 90s as a way of making various common web tasks easier and less repetitive. Back
then, the main goal was to have the minimum amount of logic as was possible in order to
achieve results, and this led to PHP being HTML-centric – that is, PHP code was embedded
inside HTML.
The first popular version of PHP was called PHP/FI 2.0, for Personal Home Page / Form
Interpreter, and, despite its parsing inconsistencies, managed to attract a fair few converts,
including myself. The main issue with this version was that the PHP/FI parser was largely
hand-written, and so users often encountered scripting errors that were not technically
errors – they were just the PHP/FI parser screwing up. Furthermore, the parser was
absolutely tied to the Apache web server, and was hardly renowned for its speed.
PHP 3 also finally made the language extensible – something that was serious lacking from
prior versions. Particularly keen developers were able to write their own modules for the
language, adding functionality at the core level. The parser itself, though, was still tied to
Apache, and, although speed was improved a great deal from PHP/FI, it still was not
anything to shout about.
The only downside to upgrading to PHP 3 was that the language was a lot stricter – some
code that worked on PHP/FI would no longer work after upgrading. The language was still
young, though, so not many were affected.
With PHP 3, the language had gained limited object-oriented support, and this only added
extra fuel to the fire of PHP's growth. By the time PHP 3 was replaced in the middle of 2000,
it was installed on over 2,500,000 web-site domains, as compared to 250,000 just 18
months before.
In the middle of 2000, PHP 4 was released to the world, containing major differences to PHP
3 in all aspects. Extensive work had been done to ensure that backwards compatibility with
older PHP scripts would remain – upgrading from PHP 3 to PHP 4 was much smoother than
the PHP/FI to PHP 3 upgrade.
Perhaps the most important change made for PHP 4 was the switch to what is called the
Zend Engine. The Zend Engine, created by Zend, a company founded by Zeev Suraski and
Andi Gutmans (the name Zend is a contraction of ZEev and aNDi) to promote PHP in the
corporate environment, allowed much more flexibility than had ever been seen in PHP
before. The engine took over the core of PHP and introduced reference counting, whereby
all resources used in scripts (database connections, files, etc) are tracked automatically by
the engine, and freed when no longer used to minimise memory usage and ensure there
were no memory leaks.
Also introduced with PHP 4 was complete web server abstraction, meaning that PHP now
runs on Apache 1.3.x, Apache 2, Microsoft's IIS, Zeus, AOLServer, and more. This opened use
of the language up to the 40% of the world who do not use Apache for their web server.
PHP 4 adopted the "compile first, execute later" paradigm, reading in your entire script and
compiling it to byte code before execution. This resulted in a large speed increase - the
average being around 100% - with some benchmarks showing up to a fifty-fold increase in
speed when PHP 4 was pushed to its limits.
PHP 5 was a big step forward for the language, although admittedly not as big as the jump
from PHP 3 to PHP 4. The release is focused on language maturity, and offers a lot of new
functionality that has simply been missing from previous versions simply because the
language was a little too simple to properly support larger projects.
PHP 5 brought with it huge steps forward for object-oriented scripts – developers are now
able to declare how their objects may be used, which makes it easier for one developer to
work with another's code. Furthermore, there is a wide variety of functions available for
objects that make them much more flexible and easy to work with – unified constructors are
only available from v5 upwards.
PHP 5 also brought with it new error checking in the form of try/catch – something that
programmers from other languages had been enjoying for a long time. Furthermore, objects
are now always handled as references in order to help programmers who just do not
understand how objects work.
A PHP file may contain text, HTML tags and scripts. Scripts in a PHP file are executed on
the server.
What is PHP?
PHP stands for PHP: Hypertext Preprocessor
PHP is a server-side scripting language, like ASP
PHP scripts are executed on the server
PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL,
Generic ODBC, etc.)
PHP is an open source software (OSS)
PHP is free to download and use
What is MySQL?
MySQL is a database server
MySQL is ideal for both small and large applications
MySQL supports standard SQL
MySQL compiles on a number of platforms
MySQL is free to download and use
PHP + MySQL
PHP combined with MySQL are cross-platform (means that you can develop in
Windows and serve on a Unix platform)
Why PHP?
PHP runs on different platforms (Windows, Linux, Unix, etc.)
PHP is compatible with almost all servers used today (Apache, IIS, etc.)
Where to Start?
Install an Apache server on a Windows or Linux machine
Install PHP on a Windows or Linux machine
Install MySQL on a Windows or Linux machine
PHP Syntax
You cannot view the PHP source code by selecting "View source" in the browser - you will
only see the output from the PHP file, which is plain HTML. This is because the scripts are
executed on the server before the result is sent back to the browser.
Anything. PHP is mainly focused on server-side scripting, so you can do anything any other
CGI program can do, such as collect form data, generate dynamic page content, or send and
receive cookies. But PHP can do much more.
There are three main areas where PHP scripts are used.
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 webserver and a web browser. You need to run the webserver, with a connected
PHP installation. You can access the PHP program output with a web browser,
viewing the PHP page through the server. All these can run on your home machine if
you are just experimenting with PHP programming. See the installation instructions
section for more information.
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. See the section about Command line usage of PHP for more
information.
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. PHP-GTK is an extension to PHP, not available in
the main distribution. If you are interested in PHP-GTK, visit its own website.
PHP can be used on all major operating systems, including Linux, many Unix variants
(including HP-UX, Solaris and OpenBSD), Microsoft Windows, Mac OS X, RISC OS, and
probably others. PHP has also support for most of the web servers today. This includes
Apache, Microsoft Internet Information Server, Personal Web Server, Netscape and iPlanet
servers, Oreilly Website Pro server, Caudium, Xitami, OmniHTTPd, and many others. For the
majority of the servers PHP has a module, for the others supporting the CGI standard, PHP
can work as a CGI processor.
So with PHP, you have the freedom of choosing an operating system and a web server.
Furthermore, you also have the choice of using procedural programming or object oriented
programming, or a mixture of them. Although not every standard OOP feature is
implemented in PHP 4, many code libraries and large applications (including the PEAR
library) are written only using OOP code. PHP 5 fixes the OOP related weaknesses of PHP 4,
and introduces a complete object model.
With PHP you are not limited to output HTML. PHP's abilities includes outputting images,
PDF files and even Flash movies (using libswf and Ming) generated on the fly. You can also
output easily any text, such as XHTML and any other XML file. PHP can autogenerate these
files, and save them in the file system, instead of printing it out, forming a server-side cache
for your dynamic content.
One of the strongest and most significant features in PHP is its support for a wide range of
databases. Writing a database-enabled web page is incredibly simple. The following
databases are currently supported:
PHP also has support for talking to other services using protocols such as LDAP, IMAP,
SNMP, NNTP, POP3, HTTP, COM (on Windows) and countless others. You can also open raw
network sockets and interact using any other protocol. PHP has support for the WDDX
complex data exchange between virtually all Web programming languages. Talking about
interconnection, PHP has support for instantiation of Java objects and using them
transparently as PHP objects. You can also use our CORBA extension to access remote
objects.
PHP has extremely useful text processing features, from the POSIX Extended or Perl regular
expressions to parsing XML documents. For parsing and accessing XML documents, PHP 4
supports the SAX and DOM standards, and you can also use the XSLT extension to transform
XML documents. PHP 5 standardizes all the XML extensions on the solid base of libxml2 and
extends the feature set adding SimpleXML and XMLReader support.
While using PHP in the e-commerce field, you'll find the Cybercash payment, CyberMUT,
VeriSign Payflow Pro and MCVE functions useful for your online payment programs.
At last but not least, we have many other interesting extensions, the mnoGoSearch search
engine functions, the IRC Gateway functions, many compression utilities (gzip, bz2),
calendar conversion, translation...
As you can see this page is not enough to list all the features and benefits PHP can offer.
Read on in the sections about installing PHP, and see the function reference part for
explanation of the extensions mentioned here.
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.
LinuxNotice how this is different from a script written in other languages like Perl or C --
instead of writing a program with lots of commands to output HTML, you write an HTML
script with some embedded code to do something (in this case, output some text). The PHP
code is enclosed in special start and end tags that allow you to jump into and out of "PHP
mode".
What distinguishes PHP from something like client-side JavaScript is that the code is
executed on the server. If you were to have a script similar to the above on your server, the
client would receive the results of running that script, with no way of determining what the
underlying code may be. You can even configure your web server to process all your HTML
files with PHP, and then there's really no way that users can tell what you have up your
sleeve.
The best things in using PHP are that it is extremely simple for a newcomer, but offers many
advanced features for a professional programmer. Don't be afraid reading the long list of
PHP's features. You can jump in, in a short time, and start writing simple scripts in a few
hours.
Although PHP's development is focused on server-side scripting, you can do much more
with it. Read on, and see more in the What can PHP do? section, or go right to the
introductory tutorial if you are only interested in web programming.
What do I need?
In this tutorial we assume that your server has activated support for PHP and that all files
ending in .php are handled by PHP. On most servers, this is the default extension for PHP
files, but ask your server administrator to be sure. If your server supports PHP, then you do
not need to do anything. Just create your .php files, put them in your web directory and the
server will automatically parse them for you. There is no need to compile anything nor do
you need to install any extra tools. Think of these PHP-enabled files as simple HTML files
with a whole new family of magical tags that let you do all sorts of things. Most web hosts
offer PHP support, but if your host does not, consider reading the PHP Links section for
resources on finding PHP enabled web hosts.
Let us say you want to save precious bandwidth and develop locally. In this case, you will
want to install a web server, such as Apache, and of course PHP. You will most likely want to
install a database as well, such as MySQL.
You can either install these individually or choose a simpler way. Our manual has installation
instructions for PHP (assuming you already have some webserver set up). In case you have
problems with installing PHP yourself, we would suggest you ask your questions on our
installation mailing list. If you choose to go on the simpler route, then locate a pre-
configured package for your operating system, which automatically installs all of these with
just a few mouse clicks. It is easy to setup a web server with PHP support on any operating
system, including MacOSX, Linux and Windows, you may findrpmfind and PBone helpful for
locating RPMs. You may also want to visit apt-get to find packages for Debian.
The point of the example is to show the special PHP tag format. In this example we used <?
php to indicate the start of a PHP tag. Then we put the PHP statement and left PHP mode by
adding the closing tag, ?>. You may jump in and out of PHP mode in an HTML file like this
anywhere you want. For more details, read the manual section on the basic PHP syntax.
A Note on Text Editors: There are many text editors and Integrated Development
Environments (IDEs) that you can use to create, edit and manage PHP files. A partial list of
these tools is maintained at PHP Editors List. If you wish to recommend an editor, please
visit the above page and ask the page maintainer to add the editor to the list. Having an
editor with syntax highlighting can be helpful.
A Note on Word Processors: Word processors such as Star Office Writer, Microsoft Word
and Abiword are not optimal for editing PHP files. If you wish to use one for this test script,
you must ensure that you save the file as plain text or PHP will not be able to read and
execute the script.
A Note on Windows Notepad: If you are writing your PHP scripts using Windows Notepad,
you will need to ensure that your files are saved with the .php extension. (Notepad adds a
.txt extension to files automatically unless you take one of the following steps to prevent it.)
When you save the file and are prompted to provide a name for the file, place the filename
in quotes (i.e. "hello.php"). Alternatively, you can click on the 'Text Documents' drop-down
menu in the 'Save' dialog box and change the setting to "All Files". You can then enter your
filename without quotes.
Now that you have successfully created a working PHP script, it is time to create the most
famous PHP script! Make a call to the phpinfo() function and you will see a lot of useful
information about your system and setup such as available predefined variables, loaded PHP
modules, and configuration settings. Take some time and review this important information.
MySQL, the most popular Open Source SQL database management system, is developed,
distributed, and supported by MySQL AB. MySQL AB is a commercial company, founded by
the MySQL developers, that builds its business by providing services around the MySQL
database management system.
The MySQLWeb site (http://www.mysql.com/) provides the latest information about MySQL
software and MySQL AB. MySQL is a database management system.
A database is a structured collection of data. It may be anything from a simple shopping list
to a picture gallery or the vast amounts of information in a corporate network. To add,
access, and process data stored in a computer database, you need a database management
system such as MySQL Server. Since computers are very good at handling large amounts of
data, database management systems play a central role in computing, as stand-alone
utilities or as parts of other applications.
Open Source means that it is possible for anyone to use and modify the software. Anybody
can download the MySQL software from the Internet and use it without paying anything. If
you wish, you may study the source code and change it to suit your needs.
The MySQL Database Server is very fast, reliable, and easy to use. If that is what we are
looking for, we should give it a try. MySQL Server also has a practical set of features
developed in close cooperation with users.
MySQL Server was originally developed to handle large databases much faster than existing
solutions and has been successfully used in highly demanding production environments for
several years. Though under constant development, MySQL Server today offers a rich and
useful set of functions. Its connectivity, speed, and security make MySQL Server highly
suited for accessing databases on the Internet.
History of MySQL
We started out with the intention of using mySQL to connect to our tables using our own
fast low-level (ISAM) routines. However, after some testing, we came to the conclusion that
mySQL was not fast enough or flexible enough for our needs. This resulted in a new SQL
interface to our database but with almost the same API interface as mySQL. This API was
designed to allow third-party code that was written for use with mySQL to be
ported easily for use with MySQL. The derivation of the name MySQL is not clear. Our base
directory and a large number of our libraries and tools have had the prefix “my” for well
over 10 years. However, co-founder Monty Widenius’s daughter is also named My. Which of
the two gave its name to MySQL is still a mystery, even for us.
The name of the MySQL Dolphin (logo) is Sakila. Sakila was chosen by the founders of
MySQL AB from a huge list of names suggested by users in our “Name the Dolphin” contest.
The winning name was submitted by Ambrose Twebaze, open source software 6 MySQL
Technical Reference for Version 5.0.0-alpha developer from Swaziland, Africa. According to
Ambrose, the name Sakila has its roots in SiSwati, the local language of Swaziland. Sakila is
also the name of a town in Arusha, Tanzania, near Ambrose’s country of origin, Uganda.
The following list describes some of the important characteristics of the MySQL Database
Software.
Column Types
Full operator and function support in the SELECT and WHERE clauses of queries.
For example: mysql> SELECT CONCAT (first_name, ' ', last_name)
-> FROM tbl_name
-> WHERE income/dependents > 10000 AND age > 30;
Full support for SQL GROUP BY and ORDER BY clauses. Support for group functions
(COUNT(), COUNT(DISTINCT ...), AVG(), STD(), SUM(), MAX(), MIN(), and
GROUP_CONCAT()).
Support for LEFT OUTER JOIN and RIGHT OUTER JOIN with both standard
SQL and ODBC syntax.
Support for aliases on tables and columns as required by standard SQL.
DELETE, INSERT, REPLACE, and UPDATE return the number of rows that were
changed (affected). It is possible to return the number of rows matched instead by
setting a flag when connecting to the server.
The MySQL-specific SHOW command can be used to retrieve information about
databases, tables, and indexes. The EXPLAIN command can be used to determine
how the optimizer resolves a query.
Function names do not clash with table or column names. The only restriction is that
for a function call, no spaces are allowed between the function name and the ‘(’ that
follows it.
We can mix tables from different databases in the same query
Security
A privilege and password system that is very flexible and secure, and allows host-
based verification. Passwords are secure because all password traffic is encrypted
when you connect to a server.
Handles large databases. We use MySQL Server with databases that contain 50
million records. We also know of users that use MySQL Server with 60,000 tables and
about 5,000,000,000 rows.
Up to 32 indexes per table are allowed. Each index may consist of 1 to 16 columns or
parts of columns. The maximum index width is 500 bytes (this may be changed when
compiling MySQL Server). An index may use a prefix of a CHAR or VARCHAR column.
Connectivity
Clients may connect to the MySQL server using TCP/IP sockets on any platform. On
Windows systems in the NT family (NT, 2000, or XP), clients may connect using
named pipes. On UNIX systems, clients may connect using UNIX domain socket files.
The Connector/ODBC interface provides MySQL support for client programs that use
ODBC (Open-Database-Connectivity) connections. For example, you can use MS
Access to connect to your MySQL server. Clients may be run on Windows or UNIX.
Connector/ODBC source is available. All ODBC 2.5 functions are supported, as are
many others.
The Connector/JDBC interface provides MySQL support for Java client programs that
use JDBC connections. Clients may be run on Windows or UNIX. Connector/JDBC
source is available.
Localization
The MySQL server has built-in support for SQL statements to check, optimize, and
repair tables. These statements are available from the command line through the
mysqlcheck client.
All MySQL programs can be invoked with the --help or -? options to obtain
Online assistance.
MySQL Stability
This section addresses the questions “How stable is MySQL Server?” and “Can I depend on
MySQL Server in this project?” We will try to clarify these issues and answer some important
questions that concern many potential users. The information in this section is based on
data gathered from the mailing list, which is very active in identifying problems as well as
reporting types of use.
The MySQL Server design is multi-layered with independent modules. Some of the newer
modules are listed here with an indication of how well-tested each of them is:
Replication — Gamma Large groups of servers using replication are in production use, with
good results.
MySQL Version 3.22 had a 4GB (4 gigabyte) limit on table size. With the MyISAM storage
engine in MySQL Version 3.23, the maximum table size was increased to 8 million terabytes
(2 ^ 63 bytes). With this larger allowed table size, the maximum effective table size for
MySQL databases now normally is determined by operating system constraints on file sizes,
not by MySQL internal limits.
The InnoDB storage engine maintains InnoDB tables within a table space that can be created
from several files. This allows a table to exceed the maximum individual file size. The table
space can include raw disk partitions, which allows extremely large tables. The maximum
table space size is 64 TB.