what is PHP?

Posted on 2000-04-05
Medium Priority
Last Modified: 2008-07-03
what is PHP?
can you explain it in more details?
Question by:mwhuen

Expert Comment

ID: 2687377
PHP is a server-side, cross-platform, HTML embedded scripting language.
More information at


Expert Comment

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

Expert Comment

ID: 2689035
2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)


Expert Comment

ID: 2699597
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.


Expert Comment

ID: 2706804
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.

Accepted Solution

Pankaj791 earned 15 total points
ID: 2720780
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 } ?>

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question