What Is PHP?

only for RuBoard - do not distribute or recompile

What Is PHP?

PHP is an interpreted language. It strongly resembles the C language. It also has some flavor of the Perl language. It is available for almost all platforms, including Linux, other versions of the Unix family, and Windows.

PHP enables you to generate Web pages on-the-fly . You do this by pulling data from databases or files, manipulating that data, and then sending that data to a Web browser.

Using PHP, you can update databases, create databases, and perform mathematical calculations (including complex trigonometric functions). You can also create and delete arbitrary files on your system, depending on the level of security at which you have PHP running. You can create Internet network connections and service those connections. It is theoretically possible to write a Web server using PHP. You are limited only by your imagination .

GEEK SPEAK: Languages are either interpreted or compiled. An interpreter is a program that reads the file containing the code to be executed, and immediately acts upon it. The code in the file is called source code. In general, the code is readable and understandable by a person.

A compiler is a program that reads the source code file and compiles the program into binary code that can be executed directly by the computer. This binary code can't be read and understood by most people.

How It Works

The Web server generally runs PHP when a user requests a Web page that contains PHP code. Typically, the Web server is configured to use the filename extension to determine whether to run PHP. For example, a Web server will look at a Web page, and if it ends in .htm or in .html, the Web server will not attempt to execute any PHP script. If the page ends in .php (or in .php3, depending on how you have configured the Web server), the Web server looks at the contents of the Web page.

When the Web page contains one of the following escape sequences, it will run PHP to interpret that part of the page:

  • <? "php code" ?>

  • <?php "php code" ?>

  • <% "php code" %> (Only available when the php.ini setting asp_tags is ON. OFF is the default setting.)

  • <script language="PHP"> "php code" </script>

The Web page that the user sees is a mixture of the standard HTML commands on the page and the output of the PHP interpreter.

GEEK SPEAK: HTML stands for Hypertext Markup Language, and is a widely available standard for text documents. The home page for HTML is http://www.w3.org/MarkUp/. Several versions of HTML are available. All recently produced browsers understand at least HTML version 1.1.

PHP can also be built to run as a standalone program executing a file containing PHP code. This allows you to run timed programs using cron, or long-running programs from the command line. Any output from PHP when run in this fashion goes to stdout .

GEEK SPEAK: You will often see references to stdout, stdin, and stderr when the behavior of programs is being described. Whenever a program is run under Linux, three standard channels for information are opened.

The stdin channel takes information from an input source and feeds it to the program. This is usually done from the keyboard. You can, by using pipes (the symbol) or redirection (the symbol), feed the information from files.

The stdout channel takes information from the program and sends it out to a device. This device is usually the screen on a terminal window. You can use pipes or redirection to send this output to a file or another program's standard input.

The stderr channel is for error messages, and cannot be easily redirected to a file or another program. It is typically reserved for debugging during development, and for indicating very serious errors the program cannot handle. Many programs quit immediately upon sending a message out stderr.

For example, look for all index.html files on your computer in the Web server directory. One way to do this is to run the find command, looking for files that contain html, and screen for index as part of the filename. This can be accomplished with this command line:

 [root@winbook /]# find /home/httpd/html -name "*.html" -print  grep index 

What It Does for You

With its capability to execute complex instructions on data inserted into or retrieved from databases, PHP is an ideal format for creating interactive Web sites. It supports multiple databases, including mSQL, MySQL, Informix, and Oracle.

PHP allows you to quickly generate interactive Web pages. Because it is interpreted, you don't have to go through any extra steps to use your program. Changes can be made to your Web page and tested immediately.

This allows you to learn in a stepwise fashion. It is perfectly acceptable to test each line of code as you go, noting the effects of each change.

Because Linux, Apache, and PHP are free, and because MySQL is free on Linux for most uses, you can inexpensively set up a test machine. This enables you to duplicate your production environment and test changes. This is critical when modifying software because it allows you to make as many mistakes as you need to without affecting your customers.

Getting Online Help for PHP

Help for PHP is available at http://www.php.net. Online documentation along with FAQs and mailing lists is available at that site.

only for RuBoard - do not distribute or recompile


MySQL and PHP From Scratch
MySQL & PHP From Scratch
ISBN: 0789724405
EAN: 2147483647
Year: 1999
Pages: 93
Authors: Wade Maxfield

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net