AbleStable®
go to Reviewsgo to Servicesgo to Registered Usersgo to Resource Centrego to AbleStable: Helpgo to About Us
go to AbleStable: Home Articles
go to Search

go to Exhibitions Centre
  Web Design: advice and help to improve your web site  
go to Help
go to Resource Centre
go to Library
go to Articles
go to E-Books
go to Glossary
go to Reviews
go to Web Link
Library > Articles > Web Design > 022

E-mail this web page address to a friend or colleague
Enter their email address below (no record is kept of this action)

     

Understanding PHP: Part 1 | Part 2
Contributor: Paul Oldham

In this second installment of his extended article introducing Internet PHP, Paul Oldham provides an outline guide to forms, functions, obtaining PHP, and a general index of PHP4 features.

Forms

One of the most powerful features of PHP is the ease with which you can handle forms. If you make your PHP script the action of the form then all the fields in the form appear as variables in your script automatically, ready for you to use. To take a simple example, suppose you have a page containing a form such as the one at the top of Figure 4. When the user clicks on the submit button the page action.php3 will be invoked to process that form. In action.php3 you might have the line of code at the bottom of Figure 4. As you can see, the input fields “age” and “name” have automatically become variables of the script action .php3, with names “$name” and “$age” ready for you to do what you like with them (in this case echoing them as part of the line of HTML).

<form action="action.php3" method="POST">
Your name: <input type=text name=name>
Your age: <input type=text name=age>
<input type=submit>
</form>


action.php3:

<p>Hello <?php echo $name?>. You are <?php echo $age?> years old.

Figure 4 - Forms in PHP - see main text.

Functions


The real strength of PHP lies in the extensive range of built-in functions. Those available include functions to:

Access a wide variety of databases (see below).

Interrogate the Web server on which the code is running.

Manipulate arrays.

Access a full range of mathematical functions.

Perform arbitrary precision mathematics (log, trig etc).

Get the date and time and display them in a variety of formats.

Browse directory trees.

Execute external programs on the server and receive the results back.

Perform a wide variety of operations on the server file system.

Set cookies.

Send mail.

Perform network functions such as “Get the Internet host name corresponding to a given IP address”.

Use Perl-compatible or POSIX-extended regular expressions.

Use System V semaphores and shared memory o Manipulate strings.

Test a variable’s current type.

Use WDDX to easily exchange data with other applications over the Web.

Gzip and gunzip files.

Creating powerful Web applications inevitably means storing and manipulating a lot of data, so the ability to access databases is vital. PHP includes support, via function calls, for a wide variety of popular databases, including Adabase D, dBase, Unix dbm, filePro, Interbase, Informix, Microsoft SQL Server, mSQL, MySQL, Oracle, Sybase, PostgreSQL, and Solid. In addition, any database which supports ODBC, such as Microsoft Access, can be used. If you’re trying to create an application which isn’t database-specific then there are a number of open source abstraction layers available, including Metabase and phpDB, which will let you do this painlessly.

Obtaining PHP

The home of PHP on the Web is www.php.net, and Zend Technologies have their own site at www.zend.com. These two sites between them contain links to an ever increasing list of other sites devoted to PHP. PHP is open source, so you can simply download PHP from many one of the many mirror sites. PHP also comes as a package in some Linux distributions.

If the target audience for your PHP-generated pages is the Web rather than your company intranet, then a growing number of ISPs can provide you with Web hosting on servers which support PHP, and an SQL database back-end, usually MySQL.

PHP4
Features

PHP4 is significantly faster than PHP3. This improvement in performance is particularly noticeable with larger and more complex scripts, and is the result of the PHPengine having been totally rewritten by Andi Gutmans and Zeev Suraski. The new Zend engine uses a much more efficient “compile-then-execute” method, instead of the “execute-while-parsing” model used by PHP3. The authors claim the resulting engine is up to fifty times faster than the PHP3 engine. Features in PHP4 include:

Extended API module.

Generalized build process under Unix.

Generic Web server interface that also supports multi-threaded Web servers.

Improved syntax highlighter.

Native http session support.

Output buffering support.

A more powerful configuration system.

Reference counting.

ftp support.

PHP4 also provides COM/DCOM support (on Windows only), allowing you to seamlessly access COM objects and instantiate them. PHP4 also has a number of additional optional functions which,with the right libraries, extend PHP to allow you to process credit cards and other financial transactions using Verisign Payment Services, and to handle Internet payments
.



Copyright Notice

Paul Oldham © 2002-2007 All Rights Reserved.
This article must not be reproduced without the explicit permission of the author.




Understanding PHP: Part 1 | Part 2



     
       
 
Authors background

This article by Paul Oldham, a Technical Consultant for the magazine PC Network Advisor, first appeared as a guide at Tech Support Alert. You can find Paul's website at http://www.the-hug.co.uk/.

If you observe inaccuracies in our in-house contributions or wish to contribute an article or review to be included at AbleStable® visit Feedback.

Copyright Notice
Although our contents are free to browse, copyright resides with the originators of all works accessed at AbleStable®, and unauthorised copying or publication of our site contents is strictly prohibited. 


AbleStable © 2002-2007
 
     
       

 All Material: AbleStable © 2002-2007
go to Frequently Asked Questionsgo to Feedbackgo to Press Centrego to Privacy Statement