Separation of Lanthanides/ Lanthanides and Actinides
Article 01 What Is Php
1. PHP Made Easy by Dr. Perl1
What is PHP?
PHP (recursive acronym for quot;PHP: Hypertext Preprocessorquot;) is a widely-used Open Source general-purpose scripting
language that is especially suited for Web development and can be embedded into HTML.
Simple answer, but what does that mean? An example:
Example: An introductory example
<html>
<head>
<title>Example</title>
</head>
<body>
<?php
echo quot;Hi, I'm a PHP script!quot;;
?>
</body>
</html>
The above written quote and example is from PHP's official manual. Let me explain and introduce you with PHP in
some more detail.
Most of us spend a few hours on internet to check/send emails, view/post something to a discussion board (like this
one), to search for some solutions using search engines, do some orkut or facebook. But a few of us will ever realize
that what has made these sites so powerful, intelligent and self-maintaining?
Very simple answer to this question is: Web Application Development Technologies.
Don't get afraid of this heavy words term - it's all about the techniques and how you use 'em. Another simple answer
would be the, PHP, ASP (Active Server Pages), JSP(Java Server Pages), CFM (Cold Fusion Markup Language) or PERL
(Practical Extraction and Reporting Language). These are most renowned web scripting languages and are widely
used to develop (or simply program) a website to register users, allow them to post topics, view topics, chat with
friends and etc etc.
In this series (PHP Made Easy by Dr. Perl) I will introduce you to the PHP, what it can do and how you can benefit
from PHP?
You can use PHP to:
• Print current date and time on your website.
• Print greetings to your visitors based on time, like Good Morning, Good Noon and etc.
• Ask comments about your article.
• Offer subscription to your weekly news letter.
drperl@hotmail.com
2. PHP Made Easy by Dr. Perl2
• Register visitors to enjoy member services.
• Enable your website to accept online payments, via Credit Cards, PayPal and etc.
• Keep track of daily visits on your website.
• Collect statistical data from daily visits, to find out that how long a user stayed on your website and which
pages were browsed mostly and likewise.
• Administer your website remotely, so that you won't need to create page locally and then to upload - called
CMS (Content Management System)
• and a very long list to go...
First things first - I mean before you get more excited, let's prepare an environment where you can practice PHP and
can create your website.
All you have to do is to download Apache, MySQL and PHP - just install and configure - and you are good to go!!!
Sounds crazy? Don't worry :) this isn't a big deal, just a matter of few clicks. Simply download XAMPP from
http://www.apachefriends.org/download.php?xampp-win32-1.7.0-installer.exe. This is a windows based installer
which will install and configure everything for you. During installation it will ask you a few questions, just proceed
with clicks - But take care of only one thing that you need to select option for Apache and MySQL to run as a service -
when asked.
Once you have installed xampp, look for the quot;htdocsquot; folder under the installation of your xampp location. This is the
folder where you will place all of your PHP files. The better idea is to create separate folders for each project (or
website).
Quick Note:
Apache - Web Server
MySQL - Database Server
Say Hello to World
The most popular and common first-code, a developer/programmer tries is quot;A Hello Worldquot; example. Fire up your
note pad and write following code in a new file.
<?php
echo quot;Hello Worldquot;;
?>
Save the file as quot;helloWorld.phpquot; under quot;htdocsquot; folder. Now fire up your favorite web browser (Firefox, IE, Opera,
Safari or etc) and type in the following address (URL) in browser's address bar.
http://localhost/helloWorld.php]http://localhost/helloWorld.php
This should load your helloWorld.php and should say:
drperl@hotmail.com
3. PHP Made Easy by Dr. Perl3
Hello World
in the browser's web page display area. Waowww... we've got another developer... ;D
Now let's have a closer look into our first PHP code (usually called script).
<?php
...
?>
The <? and ?> are the opening and closing markers (tags) of a PHP script, respectively. As I have mentioned earlier in
this article that PHP can be embedded in HTML, so the web server has to understand that which part of the web page
will be parsed (handled) by PHP itself. Usually, when we save a file as .php extension, web server automatically hands
over the calls to PHP compiler (because web server is configured for handling php files also - don't bother with it, just
carry on).
Anyway, the PHP code is enclosed between <? and ?> php tags. Alternatively you can write these tags as following
also:
<?php
...
?>
or
<?php
...
?>
Now, move on,
<?php
echo quot;Hello Worldquot;;
?>
quot;echoquot; is a PHP's language construct, which is also known as a function, but isn't a true function. However, echo
outputs one or more strings (data, numeric, alphabets or alphanumeric). Whatever you provide to echo, in double
quotes (quot;) or single quotes (') will be printed-out.
Add some more stuff
<?php
/*
My first program in PHP.
Written by Dr. Perl
*/
drperl@hotmail.com
4. PHP Made Easy by Dr. Perl4
// Print the message.
echo quot;Hello Worldquot;;
?>
As you see /*, */ and // in above code with a few english sentences - are the quot;commentsquot; or quot;remarksquot;. A comment
is what you insert in your source code to remember or to explain something about a certain part of code, about a
chunk of code or about a single line. These are helpful for you. You can use comments to take notes, that what
exactly the code does or what has been changed since last version of this code. However, these comments are
ignored by PHP compiler and do not affect the code.
Do some variables
<?php
/*
A simple calculator.
Adds two values and prints the result.
*/
// Define some values
$a = 10;
$b = 10;
// Addition
$c = $a + $b;
// Print out the result
echo $c;
?>
$ symbol is used to define a variable. A variable name can be anything meaningful, should start with $ sign. A variable
name itself should start with alphabet and can have numerics after that. The above code defines 3 variables, $a, $b
and $c. $a and $b contains values while $c contains the result of $a + $b (after addition). quot;echoquot; simply prints out the
$c (whatever it contains).
Alternatively, you can write above code as:
<?php
/*
A simple calculator.
Adds two values and prints the result.
*/
// Define some values
$a = 10;
$b = 10;
drperl@hotmail.com
5. PHP Made Easy by Dr. Perl5
// Print out the result
echo ($a + $b);
?>
Notice the 3rd variable $c is missing, because I have directly written the calculation part in the echo statement. I have
put parenthesis around the $a + $b to make it sure that it should be calculated first then should be printed out (ah!
the maths - I don't like really!!). Try it without parenthesis and figure out the results.
Summing Up
So far you have got a basic introduction to PHP, Setting up quick environment and writing basic script. Do some
practices, below is a list of few useful links which you should keep in your favorites list and may need anytime for
quick references.
Resources
www.zend.com - The PHP Company, find manual, tutorials and etc.
www.php.net - Home of PHP, find manual, and php downloads
www.mysql.com - MySQL official website
www.welive.ws - Get free space for your own website, PHP supported
www.esearchbook.com - Download free books, videos, tutorials and Share your own
www.freebookforeveryone.com - Online readable free books on PHP, PERL, Java, MySQL and etc.
Written by Dr. Perl
drperl@hotmail.com
drperl@hotmail.com