Solved

what is PHP?

Posted on 2000-04-05
6
322 Views
Last Modified: 2008-07-03
what is PHP?
can you explain it in more details?
0
Comment
Question by:mwhuen
6 Comments
 
LVL 8

Expert Comment

by:us111
ID: 2687377
PHP is a server-side, cross-platform, HTML embedded scripting language.
More information at
http://www.php.net/tut.php3

0
 

Expert Comment

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

Expert Comment

by:us111
ID: 2689035
yep
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Expert Comment

by:qader99
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.



0
 
LVL 1

Expert Comment

by:andrewljohn70
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.
0
 

Accepted Solution

by:
Pankaj791 earned 5 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.





www.php.net
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.
<html><body>
<?php
echo "Hello World";
?>
</body></html>

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)

<?php
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>
</form>

Action.php3:
<html><body>
Hi <?php echo $name?>. You are <?php echo $age?> years old.
</body></html>

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.

Example:
<html><body>
<?php phpinfo(); ?>
</html></body>

gives output like: Variable Value
HTTP_ACCEPT_LANGUAGE en-nz
HTTP_CONNECTION Keep-Alive
HTTP_HOST localhost
HTTP_REFERER HTTP://localhost/
HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)
HTTP_ACCEPT_ENCODING gzip, deflate HTTPS off
CMDLINE WIN
CONTENT_LENGTH 0
GATEWAY_INTERFACE CGI/1.1
REMOTE_ADDR 127.0.0.1
REQUEST_METHOD GET


The combination of Mysql and PHP goes really good. And they support both the unix and windows platforms.
<html><body>
<?php
$db = mysql_connect("localhost", "root");
mysql_select_dB("mydb",$dB);
$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"));
?>
</html></body>
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.

<html><body>
<?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 } ?>
</html></body>
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now