2006-01-11 12:47:17 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2007-02-15 09:24:37 +00:00
|
|
|
<!-- $Revision: 1.43 $ -->
|
1999-06-06 18:51:02 +00:00
|
|
|
<chapter id="introduction">
|
2006-01-11 12:47:17 +00:00
|
|
|
<title>Introduction</title>
|
1999-06-06 18:51:02 +00:00
|
|
|
|
|
|
|
<sect1 id="intro-whatis">
|
2006-01-11 12:47:17 +00:00
|
|
|
<title>What is PHP?</title>
|
2001-11-10 11:57:06 +00:00
|
|
|
<para>
|
2006-01-11 12:47:17 +00:00
|
|
|
<acronym>PHP</acronym> (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.
|
2001-11-10 11:57:06 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2006-01-11 12:47:17 +00:00
|
|
|
Simple answer, but what does that mean? An example:
|
1999-12-19 17:16:54 +00:00
|
|
|
</para>
|
1999-06-19 21:58:55 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
2006-01-11 12:47:17 +00:00
|
|
|
<title>An introductory example</title>
|
1999-12-19 20:13:06 +00:00
|
|
|
<programlisting role="php">
|
2001-11-09 15:48:16 +00:00
|
|
|
<![CDATA[
|
|
|
|
<html>
|
|
|
|
<head>
|
2006-01-11 12:47:17 +00:00
|
|
|
<title>Example</title>
|
2001-11-09 15:48:16 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
2001-11-10 11:57:06 +00:00
|
|
|
|
2001-11-09 15:48:16 +00:00
|
|
|
<?php
|
2006-01-11 12:47:17 +00:00
|
|
|
echo "Hi, I'm a PHP script!";
|
2001-11-09 15:48:16 +00:00
|
|
|
?>
|
2001-11-10 11:57:06 +00:00
|
|
|
|
2001-11-09 15:48:16 +00:00
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
]]>
|
1999-06-19 21:58:55 +00:00
|
|
|
</programlisting>
|
1999-12-19 17:16:54 +00:00
|
|
|
</example>
|
|
|
|
</para>
|
1999-06-20 01:21:17 +00:00
|
|
|
<para>
|
2006-01-11 12:47:17 +00:00
|
|
|
Notice 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 <link
|
|
|
|
linkend="language.basic-syntax.phpmode">start and end tags</link>
|
|
|
|
that allow you to jump into and out of "PHP mode".
|
1999-12-19 17:16:54 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2006-01-11 12:47:17 +00:00
|
|
|
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.
|
1999-12-19 17:16:54 +00:00
|
|
|
</para>
|
2001-11-10 11:57:06 +00:00
|
|
|
<para>
|
2006-01-11 12:47:17 +00:00
|
|
|
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.
|
2001-11-10 11:57:06 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2006-01-11 12:47:17 +00:00
|
|
|
Although PHP's development is focused on server-side scripting,
|
|
|
|
you can do much more with it. Read on, and see more in the
|
|
|
|
<link linkend="intro-whatcando">What can PHP do?</link> section,
|
|
|
|
or go right to the <link linkend="tutorial">introductory
|
|
|
|
tutorial</link> if you are only interested in web programming.
|
2001-11-10 11:57:06 +00:00
|
|
|
</para>
|
1999-12-19 17:16:54 +00:00
|
|
|
</sect1>
|
1999-06-06 18:51:02 +00:00
|
|
|
|
|
|
|
<sect1 id="intro-whatcando">
|
2006-01-11 12:47:17 +00:00
|
|
|
<title>What can PHP do?</title>
|
|
|
|
<para>
|
|
|
|
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.
|
2001-11-10 11:57:06 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2006-01-11 12:47:17 +00:00
|
|
|
There are three main areas where PHP scripts are used.
|
2001-11-10 11:57:06 +00:00
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<simpara>
|
2006-01-11 12:47:17 +00:00
|
|
|
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
|
2007-02-15 09:24:37 +00:00
|
|
|
module), a web server and a web browser. You need to
|
|
|
|
run the web server, with a connected PHP installation.
|
2006-01-11 12:47:17 +00:00
|
|
|
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
|
|
|
|
<link linkend="install">installation instructions</link>
|
|
|
|
section for more information.
|
2001-11-10 11:57:06 +00:00
|
|
|
</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>
|
2006-01-11 12:47:17 +00:00
|
|
|
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
|
|
|
|
<link linkend="features.commandline">Command line usage of PHP</link>
|
|
|
|
for more information.
|
2001-11-10 11:57:06 +00:00
|
|
|
</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>
|
2006-01-11 12:47:17 +00:00
|
|
|
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 <ulink url="&url.php.gtk;">its
|
|
|
|
own website</ulink>.
|
2001-11-10 11:57:06 +00:00
|
|
|
</simpara>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</para>
|
|
|
|
<para>
|
2006-01-11 12:47:17 +00:00
|
|
|
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.
|
1999-12-19 17:16:54 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2006-01-11 12:47:17 +00:00
|
|
|
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.
|
2001-11-10 11:57:06 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2006-01-11 12:47:17 +00:00
|
|
|
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.
|
2001-11-10 11:57:06 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2006-01-11 12:47:17 +00:00
|
|
|
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:
|
1999-06-06 18:51:02 +00:00
|
|
|
<blockquote>
|
1999-10-20 22:46:26 +00:00
|
|
|
<simplelist columns="3">
|
1999-06-06 18:51:02 +00:00
|
|
|
<member>Adabas D</member>
|
|
|
|
<member>dBase</member>
|
|
|
|
<member>Empress</member>
|
2006-01-11 12:47:17 +00:00
|
|
|
<member>FilePro (read-only)</member>
|
2000-10-27 07:59:39 +00:00
|
|
|
<member>Hyperwave</member>
|
2000-08-07 05:31:47 +00:00
|
|
|
<member>IBM DB2</member>
|
1999-06-06 18:51:02 +00:00
|
|
|
<member>Informix</member>
|
2000-08-07 05:31:47 +00:00
|
|
|
<member>Ingres</member>
|
1999-06-06 18:51:02 +00:00
|
|
|
<member>InterBase</member>
|
2000-08-07 05:31:47 +00:00
|
|
|
<member>FrontBase</member>
|
1999-06-06 18:51:02 +00:00
|
|
|
<member>mSQL</member>
|
2000-08-07 05:31:47 +00:00
|
|
|
<member>Direct MS-SQL</member>
|
1999-06-06 18:51:02 +00:00
|
|
|
<member>MySQL</member>
|
2000-08-07 05:31:47 +00:00
|
|
|
<member>ODBC</member>
|
2006-01-11 12:47:17 +00:00
|
|
|
<member>Oracle (OCI7 and OCI8)</member>
|
2000-10-27 07:59:39 +00:00
|
|
|
<member>Ovrimos</member>
|
1999-06-06 18:51:02 +00:00
|
|
|
<member>PostgreSQL</member>
|
2004-05-23 19:32:27 +00:00
|
|
|
<member>SQLite</member>
|
1999-06-06 18:51:02 +00:00
|
|
|
<member>Solid</member>
|
|
|
|
<member>Sybase</member>
|
|
|
|
<member>Velocis</member>
|
|
|
|
<member>Unix dbm</member>
|
|
|
|
</simplelist>
|
1999-12-19 17:16:54 +00:00
|
|
|
</blockquote>
|
2006-08-13 22:08:54 +00:00
|
|
|
We also have a database abstraction extension (named PDO) allowing you
|
2006-01-11 12:47:17 +00:00
|
|
|
to transparently use any database supported by that extension.
|
|
|
|
Additionally PHP supports ODBC, the Open Database Connection
|
|
|
|
standard, so you can connect to any other database supporting
|
|
|
|
this world standard.
|
1999-12-19 17:16:54 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2006-01-11 12:47:17 +00:00
|
|
|
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.
|
2001-11-10 11:57:06 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2006-01-11 12:47:17 +00:00
|
|
|
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.
|
2001-11-10 11:57:06 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2006-01-11 12:47:17 +00:00
|
|
|
At last but not least, we have many other interesting
|
|
|
|
extensions, the mnoGoSearch search engine functions,
|
|
|
|
the IRC Gateway functions, many compression utilities
|
2006-08-13 22:08:54 +00:00
|
|
|
(gzip, bz2, zip), calendar conversion, translation...
|
2001-11-10 11:57:06 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2006-01-11 12:47:17 +00:00
|
|
|
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 <link linkend="install">installing
|
|
|
|
PHP</link>, and see the <link linkend="funcref">function
|
|
|
|
reference</link> part for explanation of the extensions
|
|
|
|
mentioned here.
|
2001-11-10 11:57:06 +00:00
|
|
|
</para>
|
1999-12-19 17:16:54 +00:00
|
|
|
</sect1>
|
1999-06-06 18:51:02 +00:00
|
|
|
|
|
|
|
</chapter>
|
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
2001-12-12 20:47:43 +00:00
|
|
|
indent-tabs-mode:nil
|
1999-06-06 18:51:02 +00:00
|
|
|
sgml-parent-document:nil
|
1999-12-19 17:16:54 +00:00
|
|
|
sgml-default-dtd-file:"../../manual.ced"
|
1999-06-06 18:51:02 +00:00
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
2001-09-21 22:47:49 +00:00
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
1999-06-06 18:51:02 +00:00
|
|
|
-->
|