what is PHP?

what is PHP?
can you explain it in more details?
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Pankaj791Connect With a Mentor Commented:
This is a small epitome of a presentation I made a few days back. Go through it and you should have a fair Idea of what PHP is.

HTTP://hotwired.lycos.com/webmonkey/99/21/index2a.html (PHP/MySQL Tutorial by Graeme Merrall)

Enter PHP and MySQL. These two make up what must be the best combination for data-driven Web sites on the planet. You needn't take my word for it. An unofficial Netcraft survey shows that PHP usage has jumped from 7,500 hosts in June 1998 to 410,000 in March 1999. That's not bad.

PHP is a server-side, cross-platform, HTML embedded scripting language. If you've seen ASP, you'll be familiar with embedding code within an HTML page. Like ASP, PHP script is processed by the Web server. After the server plays with the PHP code, it returns plain old HTML back to the browser. This kind of interaction allows for some pretty complex operations.

Also, PHP can be run as an external CGI process, a stand-alone script interpreter, or an embedded Apache module.

If you're interested, PHP also supports a massive number of databases, including Informix, Oracle, Sybase, Solid, and PostgreSQL - as well as the ubiquitous ODBC.

PHP supports a host of other features right at the technological edge of Internet development. These include authentication, XML, dynamic image creation, WDDX, shared memory support, and dynamic PDF document creation to name but a few. If that's not enough, PHP is easy to extend, so you can roll your own solution if you're programming savvy.

The home of PHP is HTTP://www.php.net/. The PHP site is a mine of information, from project listings to bug reports.

Now that we are getting involved let's proceed further.
echo "Hello World";

If you view the HTML source for the page, you'll see that there is only the text. Hello World That's because the PHP engine has examined the page, processed any code blocks that it found, and returned only HTML. The first thing you'll notice about the script above are the delimiters. These are the lines that start indicates the end of the block. The power of PHP is that these can be placed anywhere - and I mean anywhere.

Start with more useful things: 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; ?>

There are many other 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(); ?>
(we will give the example of a few of them later on)

if(strstr($HTTP_USER_AGENT,"MSIE")) { echo "You are using Internet Explorer <br>"; }

<?php if(strstr($HTTP_USER_AGENT,"MSIE")) { ?>
You are using Internet Explorer
<? } else { ?>
You are not using Internet Explorer
<? } ?>

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. FORM:
<form action="action.php3" method="POST">
Your name: <input type=text name=name>
You age: <input type=text name=age>
<input type=submit>

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

The real power of PHP comes from its functions. These are basically processing instructions. If you add up all of the optional add-ins to PHP, there are more than 700 functions available. So there's quite a bit you can do.

<?php phpinfo(); ?>

gives output like: Variable Value
HTTP_HOST localhost
HTTP_REFERER HTTP://localhost/ 
HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)

The combination of Mysql and PHP goes really good. And they support both the unix and windows platforms.
$db = mysql_connect("localhost", "root");
$result = mysql_query("SELECT * FROM employees",$dB);
printf("First Name: %s\n", mysql_result($result,0,"first"));
printf("Last Name: %s\n", mysql_result($result,0,"last"));
printf("Address: %s\n", mysql_result($result,0,"address"));
printf("Position: %s\n", mysql_result($result,0,"position"));
Also note the printf used here. PHP code derives it's syntax heavily from the C language (making it easier for most programmers to start in PHP easily).

PHP goes really well with database support functionality. This is one reason for it's becoming very common lastly.

OK one use for embedded server side scripts like this is illustrated in the following Example: Suppose you have a small text which you want to include in 50 pages (could be Copyright yourcomany.com). Now in case you write it in simple HTML then you have to update 50 files to change anything in that. Instead you can do this: make a php file with just this code: echo "Copyright yourcompany.com\n"; and where ever you want this to appear (those 50 files) just add this line:
<?php include "phpfile.php" ?>

There are good functions like Mail() which can be used to send mails. There are easy methods of getting user input through forms. If you used POST then $HTTP_POST_VARS will contain all the data.

<?php if($submit) echo "You have Entered your name successfully "; else { ?>
<form action="<?php echo $PHP_SELF; ?>" method="POST">
Your name: <input type=text name=name>
<input type=submit name="submit" value="Enter" >
</form >
<?php } ?>
PHP is a server-side, cross-platform, HTML embedded scripting language.
More information at

Wow..... Do you know ASP ??? 'cause it's quite same a lot... Nopp... It is ASP in C language Nop.... Errrrrrrrrr....
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

PHP is a language which you can include in between your HTML code to add functionality to your web pages. It is ofcouse server side program so that your code would not be visible to the user.

Much of the syntax are similar to other programmin languages like C.

PHP is a server-side scripting language that can be used on a host of webservers and platforms. I prefer to use it with Apache on Linux, but it can even run on Win32 platforms.

What server-side scripting language means is that the script is put into the HTML files that make up a site, but the server processes the script BEFORE it is sent to the client browser. PHP code is not visible if you view the source of a page because the server processes the code and returns only the output. This is easier to code and debug than writing CGI scripts in Perl or C since the HTML form and related code are all in one page and PHP puts any errors on the browser.

Another advantage that PHP offers is the ability to directly connect to relational databases using full featured internal functions. It supports a whole fleet of databases including Oracle, DB2, mSQL and MySQL.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.