The remarkable volume of information which has moved to the Web over the last few years, and the complexity of delivering it dynamically to Web users, have resulted in the increased popularity of programming languages designed specifically for delivery of Web content. The PHP Hypertext Preprocessor is one of the most widely used languages in this field, found on more than 16 million Web sites (www.php.net/usage.php).
PHP is similar to Microsoft Active Server Pages, Java Servlets and Cold Fusion Module but is commonly held to be much easier to program (or 'script') with, much faster than its competitors and, best of all, it is free to use and distribute.
What is a Hypertext Preprocessor?
These programs read and translate instructions embedded in a Web page before the Web server sends it to your browser (JavaScript could be said to be a Hypertext Postprocessor in as much as it is interpreted after the delivery of the page).
It might be easier to understand this in an example: HelpScreen.com.au is powered by PHP and when you open www.HelpScreen.com.au/index.php in your Web browser, the Web server running the site asks PHP to translate any embedded instructions in the Web page. Within the page itself, PHP is "instructed to: check if the person requesting the page is logged in; generate a list of HelpScreen categories; locate the most recent questions on the site; generate the HelpScreen poll information, and much more. It is testament to the design of PHP that all this takes only a split second.
Should I use PHP?
PHP is ideal if you want your Web pages to be generated dynamically. That is, if you are finding it too laborious to update static Web pages constantly (consider how time-consuming it would be to rebuild the HelpScreen.com.au Web site every time someone asked a question!) or if your Web page needs to get information from other places, such as the system clock to display the current time, or a file or database system to display an address book.
How do I use PHP?
In order to use PHP you will need access to a Web server which runs the PHP Preprocessor. If your Web site is hosted by your ISP or a Web hosting company, you should enquire if they offer access to PHP; many do. If your Web site runs on your own server, you can install PHP on it yourself. If you are going to do this, follow these installation instructions:
Linux/UNIX users should unpack the source archive php-4.0.5.tar.gz. For information on installation, see the INSTALL file in the archive.
Windows users should unpack the Windows' binary release located in php-4.0.5-Win32.zip. Follow the instructions in install.txt for information on how to install PHP for your Web server.
If you don't have a Web server, you can use the Apache distribution. Linux/UNIX users should use apache_1.3.20.tar.gz archive. Installation information is included in the INSTALL file, as in the case of PHP. Windows users need only execute the file apache_1.3.20-win32-no_src-r2.msi. This will launch an install wizard that will guide you through the installation.
Setting up the PHP processor and your Web server is only half the story, however. Writing a PHP 'script' which will be processed by this system involves embedding instructions in a text file with the HTML you want to output. As in the case of an HTML document, this can be done with a standard text editor such as Vi or Pico on Linux/UNIX systems, or Notepad under Windows.
Let's have a look at a simple PHP script:<HTML><BODY> <? echo "Hello World!"; ?><? echo "The time is ".date('D M d H:i:s T Y')."\n"; ?> </BODY> </HTML>Save this file as hello.php and upload it to your PHP-enabled Web server. Requesting this page from your Web server with your browser will give you a page containing 'Hello World!' and a formatted current date. Notice that the PHP instructions are bracketed by <? and ?> tags - this is how the preprocessor knows the difference between HTML and PHP. PHP code (and all HTML) outside these brackets will be ignored and simply sent directly to the Web browser of the person requesting the page.
The two instructions which do the work in our example are 'echo' and 'date'. These functions are built into PHP. The echo function does what its name suggests - it 'echoes' to output the string following it. The second call to the echo function is followed by a string made up of several substrings. Next month we will look at how this works, and why it is useful in PHP.
Meanwhile, the date() function allows us to format the current date and time (see www.php.net/manual/en/function.date.php for meanings of the letters passed to the date() function). There are many other built- in PHP functions, all of which are documented in the PHP manual at www.php.net/manual/en/.
Next we will take a close look at strings in PHP as well as exploring the difference between functions and control structures (such as loops) in preparation for our first project: a PHP script which manages an online address book.
Read up on the latest ideas and technologies from companies that sell hardware, software and services. Controlling storage costs with Oracle database 11g
How to improve employee productivity in small and medium businesses
The state of Middleware
IT Service Management Needs and Adoption Trends: An Analysis of a Global Survey of IT Executives
Making the Business Case for IT Consolidation
Controlling Recreational Peer-to-Peer Traffic on Corporate Networks
Best Practices in Optimizing WAN Performance
Zones provide focussed content from Computerworld and leading technology partners.Discover how SOA can create smarter outcomes for your business.
Attend and learn:
- How SOA is helping leading companies to become more agile
- Where you should be applying SOA processes in your company
- The top SOA implementation mistakes to avoid
Click here for more information.
- +
Computerworld Live Podcast #98: The Future of Datacentre IP 18/12/2008 10:33:00
CW Live speaks withLin Nease, Director of Emerging Business for HP ProCurve, to discuss the future of networks, including the effect of IP-based storage on datacentres, new capacity requirements generated by the use of 10Gb Ethernet, and how an efficient network design can slash energy and cooling costs, and help enterprises build a "green" image. - +
Computerworld Live Podcast #97: The Future of Enterprise Networking 25/07/2008 09:45:36
This week CW Live chats with Mark Thompson, global sales and marketing manager for HP ProCurve, on the future of the enterprise networking. Mark discusses the trends we can expect to see in the near future and how the right infrastructure can ensure your enterprise network is secure. - +
Computerworld Live Podcast #96: Security at the Edge 11/06/2008 09:22:22
CW Live speaks with Amol Mitra, HP ProCurve Director of Marketing for Asia Pacific and Japan. Today's topic: how enterprises are starting to shift away from simply controlling security via server logins, firewalls and moving to more adaptive security frameworks. - +
Data Management Edition #10: Multi-Petascale Systems 02/05/2008 09:12:33
This week we look at sustainability and the development of multicore technologies to build multi-petascale systems. - +
IT Security Edition #11: How to poison the Storm botnet 01/05/2008 08:51:55
This week CW Live presents a case study on how to poison the notorious Storm botnet . Plus we take a look at Cisco's plans for Ironport.
SEAGATE SHIPS DESKTOP HARD DRIVE WITH WORLD’S HIGHEST AREAL DENSITY – 500GB PER DISK 2009-01-06 15:34:00+11
New FileMaker Pro 10 Ships With Sleek New Interface and Breakthrough Reporting and Automating Features 2009-01-06 12:21:00+11
Lexar extends KODAK offering with Secure Digital High-Capacity, High-Speed Memory Card 2009-01-06 09:36:00+11
Informatica Selected as the Data Integration Platform for BNP Paribas Assurance 2008-12-24 10:20:00+11
Informatica Announces Data Transformation Accelerator for Improving Operational Efficiency and Business Agility 2008-12-24 10:17:00+11
Strategies for Eliminating .PST Files
Join industry expert Martin Tuip to discover best practice strategy for the archival and removal of .PST files using email archiving. Learn how to ensure long-term email records are there when needed, and reduce the risk to your business and clients.






Comments
FLV Converter for Mac Video
FLV Converter for Mac
Video Converter for Mac
3GP Converter for Mac
AVI Converter for Mac
DVD Converter for Mac
DVD Creator for Mac
M4V Converter for Mac
MOV Converter for Mac
MP4 Converter for Mac
MPG Converter for Mac
PSP Converter for Mac
WMV Converter for Mac
YouTube Converter for Mac
iPod Converter for Mac
M2T Converter for Mac