WebRef Update: Featured Article: Intro to PHP | 2 | WebReference

WebRef Update: Featured Article: Intro to PHP | 2


Intro to PHP

What is PHP?

So now that I've whetted your appetite, let's learn some more about PHP.

To start off I'll throw some simple PHP code at you (this assumes you understand HTML):

basic.php3

1: <html> 2: <head> 3: <title>A Basic PHP page</title> 4: </head> 5: <body bgcolor="#ffffff" text="#000000"> 6: <?php 7: $date = date( "l F d, Y" ); 8: print( $date ); 9: ?> 10: </body> 11: </html>

The function of this code is simple. First we start off the document with the normal HTML headers, nothing new there. What is new is the material on lines 6 through 9; here we see simple PHP code which will print out the current date. Here is a line by line explanation of what happens in lines 6 through 9:

Line 6: Tells the PHP preprocessor that the PHP code has begun. This is like the <html> at the beginning of the document which tells the Web browser to treat the document as an HTML language.
Line 7: A lot going on in this line - first we initialize (assign a value to) the variable $date. The value is a formatted date generated by PHP's built in date function.
Line 8: Here we use the built in print function to print the variable $date out on the screen.
Line 9: Tell the preprocessor to stop interpreting PHP code.

This is a basic example of PHP's features, and a little bit of source code to give you the idea. This article's purpose is to introduce PHP, rather than write a tutorial on PHP. Subsequently, I'm not covering the syntax in depth but rather giving a taste of the language. Other tasks that PHP is especially good at are database access, disk access, networking and text manipulation. You can find articles that cover these features on the sites listed below.

Conclusion

In this article, we have discussed the motives for using PHP, what PHP is and even gotten into writing some source code. We have also gone over some of the history of PHP. However, this is meant only as an introduction, to help you on your way to becoming an experienced PHP programmer. For more information, I have provided a list of links which will serve to help further your knowledge of PHP. Happy trails!

Links

The Official PHP site - www.php.net
PHP Builder - www.phpbuilder.com
Devshed - www.devshed.com
Webmonkey - www.hotwired.com/webmonkey/99/21/index2a.html
Webreference - webreference.com/perl/xhoo/php1/
The Web2010 tutorial page - www.web2010.com/tutorial/
PHP Wizard - www.phpwizard.net

Author Info:

Stirling Hughes can be reached at [email protected], or at www.scalarsplit.com.

Previous: Why Use PHP?

This article originally appeared in the October 28, 1999 edition of the WebReference Update Newsletter.

https://www.internet.com

Comments are welcome
Written by Stirling Hughes and

Revised: May 16, 2000

URL: https://webreference.com/new/php2.html