PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

What can PHP do?> <Getting Started
Last updated: Fri, 15 Aug 2008

view this page in

Introduction

Table of Contents

What is PHP?

PHP (recursive acronym for "PHP: Hypertext Preprocessor") is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.

Nice, but what does that mean? An example:

Example #1 An introductory example

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>Example</title>
    </head>
    <body>

        <?php
            
echo "Hi, I'm a PHP script!";
        
?>

    </body>
</html>

Instead of lots of commands to output HTML (as seen in C or Perl), PHP pages contain HTML with embedded code that does "something" (in this case, output "Hi, I'm a PHP script!"). The PHP code is enclosed in special start and end processing instructions <?php and ?> that allow you to jump into and out of "PHP mode."

What distinguishes PHP from something like client-side JavaScript is that the code is executed on the server, generating HTML which is then sent to the client. The client would receive the results of running that script, but would not know what the underlying code was. You can even configure your web server to process all your HTML files with PHP, and then there's really no way that users can tell what you have up your sleeve.

The best things in using PHP are that it is extremely simple for a newcomer, but offers many advanced features for a professional programmer. Don't be afraid reading the long list of PHP's features. You can jump in, in a short time, and start writing simple scripts in a few hours.

Although PHP's development is focused on server-side scripting, you can do much more with it. Read on, and see more in the What can PHP do? section, or go right to the introductory tutorial if you are only interested in web programming.



What can PHP do?> <Getting Started
Last updated: Fri, 15 Aug 2008
 
add a note add a note User Contributed Notes
Introduction
nostamar $AT$ g mail
30-Jan-2008 02:06
here is a "server-php >> html >> browser" process illustration:
http://www.lastown.com/forum/viewtopic.php?t=533

it shows the basic steps; first php code is parsed at server into html; then sent to browser, that understands html tags and renders them to the display the webpage, there's also some quick overview about the process.. worths taking a look at
winks716
19-Aug-2007 05:48
before html runs to show a webpage, php code runs first on web server.

so, when there lines as follow:

<table>
<tr>
<td>
  <?php
   
echo "php runs first!";
 
?>
</td>
</tr>
</table>

the first step is to run php code, we get:

<table>
<tr>
<td>
php runs first
</td>
</tr>
</table>

then, code is sent to browser, and we see somthing~
george dot langley at shaw dot ca
19-Jul-2007 03:02
"the code is executed on the server"

This is an important concept for the first-time PHP programmer to understand, so that when you get into string formatting later on, you understand the difference between formatting the on-screen content (as parsed by your browser) and formatting the HTML code (as returned by the server).
For example "/n" starts a new line in the HTML code, and its results are only seen if you look at the "source HTML". It is NOT the same as <br>!

What can PHP do?> <Getting Started
Last updated: Fri, 15 Aug 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites