Shvoong Home > Books > PHP Tutorial Summary

.

Solve the Riddle and Win $500!

PHP Tutorial Book Review

Summary rating: 5 stars 7 Ratings
Review by : ShankarBabu
Visits : 166  words: 900   Published: October 17, 2007
1.Introduction
PHP stands for ''Hypertext Pre−Processor'' and is a server side HTML scripting/programming language. PHP
is a tool that lets you create dynamic web pages. PHP−enabled web pages are treated just like regular HTML
pages and you can create and edit them the same way you normally create regular HTML pages.
PHP was kept the "top secret and strictly confidential" computer language by many companies in the
world, but now had become the most well−known and most widely used scripting language for web, internet,
e−commerce and business−to−business projects. Even today many competing companies keep PHP language
as a highly confidential matter not disclosing to outsiders (competitors).
PHP will storm the entire world and will take the IT industry by surprise!! The power of PHP is that it is
cross−platform and runs everywhere!! It runs on Linux, Windows 95/98/NT, Windows 2000, Solaris,
HPUX and all flavors of unix. PHP is write once and deploy anywhere and everywhere. It runs on many
web−servers like Apache, Microsoft IIS, etc..
PHP runs 5 to 20 times faster than Java!! It is extremely easy to use and you can develop very complex
web/e−commerce applications very rapidly in a very short period of time.
It has object oriented features and takes the best features from Java, C++, PERL and "C" langauges. PHP
language is a marriage of best features from Java, C++, PERL and C.
PHP is the real gem of all the scripting/programming languges and will soon become the "MECCA" for
programmers world−wide!! PHP has a huge user base and a large developer base as it runs on both
window95/NT and all flavors of unixes.
PHP can be compiled and optimized to make it run even faster by using the Zend Optimizer. Zend optimizer
is integrated with PHP in PHP version 4.0.
You would normally use a combination of PHP (70% code) + HTML/DHTML/XML (25% code) +
Javascript (5% code client side validations) for your e−commerce projects.
2.PHP Download
· PHP main site http://www.php.net
· PHP resources http://ils.unc.edu/web−db/php/links.html
· PHP Code Exchange − http://px.sklar.com
PHP HOW−TO
20.Appendix J phpDBTest.php3 Example 3
2.1 PHP Installation
See the installation guide and instructions at PHP main site http://www.php.net or INSTALL file in the
downloaded package itself.
3.PHP Tutorial
In this tutorial we assume that your server has support for PHP activated and that all files ending in .php3 are
handled by PHP.
Your first PHP−enabled page: Create a file named hello.php3 and in it put the following lines:
<html>< head>< title >PHP Test< /title >< /head >
< body>
<?php echo "Hello World<P>"; ?>
< /body>< /html>
Note that this is not like a CGI script. Think of it as a normal HTML file which happens to have a set of
special tags available to you.
If you tried this example and it didn''t output anything, chances are that the server you are on does not have
PHP enabled. Ask your administrator to enable it for you.
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 all you want.
We are going to check what sort of browser the person viewing the page is using. In order to do that we check
the user agent string that the browser sends as part of its request. This information is stored in a variable.
Variables always start with a dollar−sign in PHP. The variable we are interested in is
$HTTP_USER_AGENT. To display this variable we can simply do:
<?php echo $HTTP_USER_AGENT; ?>
For the browser that you are using right now to view this page, this displays:
Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)
There are many variables that are automatically set by your web server. You can get a complete list of
them by creating a file that looks like this:
<?php phpinfo()?>
Then load up this file in your browser and you will see a page full of information about PHP along with a list
of all the variables available to you.
You can put multiple PHP statements inside a PHP tag and create little blocks of code that do more than just
a single echo.
PHP HOW−TO
2.1 PHP Installation 4
<?php
if(strstr($HTTP_USER_AGENT,"MSIE")) {
echo "You are using Internet Explorer<br>";
}
?>
We can take this a step further and show how you can jump in and out of PHP mode even in the middle of a
PHP block:
<?php
if(strstr($HTTP_USER_AGENT,"MSIE"))
{
?>
< center>< b>You are using Internet Explorer< /b>< /center>
<?
}
else
{
?>
< center>< b>You are not using Internet Explorer< /b>< /center>
<?
}
?>
Instead of using a PHP echo statement to output something, we jumped out of PHP mode and just sent
straight HTML. The important and powerful point to note here is that the logical flow of the script remain
intact. Only one of the HTML blocks will end up getting sent to the viewer. Running this script right now
results in:
You are using Internet Explorer
Dealing with Forms
One of the most powerful features of PHP is the way it handles HTML forms. The basic concept that is
important to understand is that any form element in a form will automatically result in a variable with the
same name as the element being created on the target page. This probably sounds confusing, so here is a
simple example. Assume you have a page with a form like this on it:
<form action="action.php3" method="POST">
Your name: <input type=text name=name>
You age: <input type=text name=age>
<input type=submit>
< /form>
There is nothing special about this form. It is a straight HTML form with no special tags of any kind. When
the user fills in this form and hits the submit button, the action.php3 page is called. In this file you would
have something like this:
Hi <?php echo $name?>. You are <?php echo $age?> years old.
Surprise!! The $name and $age variables are automatically set for you by PHP !!
PHP HOW−TO
2.1 PHP Installation 5
4.IDE tools for PHP
Many HTML editors are supporting PHP :
· Blue Fish http://bluefish.linuxave.net
· Coffee cup http://www.coffeecup.com/linux
· Dreamweaver http://www.dreamweaver.com
· Amaya http://www.w3.org/Amaya
· Homesite http://www.homesite.com
· Hotdog http://www.hotdog.com
· Zend Optimizers http://www.zend.com
· Zend Compilers http://www.zend.com
In near future every HTML editors and XML editor will be supporting PHP "Rapid Application
Development" tool.

More reviews about the PHP Tutorial
Please Rate this abstract : 1 2 3 4 5


Add your comment No comments

Comments & Reviews about PHP Tutorial Book Review

Read Free Summaries - Write and Get Paid

Summarize Human Knowledge on Shvoong. Join us!

------