Skip to main content
  • 762 Accesses

Abstract

One of the great payoffs of using PHP is that it can save you a lot of repetitive work. Figure 4-1 shows how four elements of a static web page benefit from a little PHP magic.

Identifying elements of a static web page that could be improved with PHP

The menu and copyright notice appear on each page. Wouldn’t it be wonderful if you could make changes to just one page and see them propagate throughout the site in the same way as with CSS? You can with PHP includes. You can even get the menu to display the correct style to indicate which page the visitor is on. Similar PHP wizardry automatically changes the date on the copyright notice and the text in the page title. PHP can also add variety by displaying a random image. JavaScript solutions fail if JavaScript is disabled, but with PHP your script is guaranteed to work all the time. The images don’t all need to be the same size; PHP inserts the correct width and height attributes in your <img> tag. And with a little extra scripting, you can add a caption to each image.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 24.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 34.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Rights and permissions

Reprints and permissions

Copyright information

© 2006 David Powers

About this chapter

Cite this chapter

(2006). Lightening Your Workload with Includes. In: PHP Solutions: Dynamic Web Design Made Easy. Apress. https://doi.org/10.1007/978-1-4302-0275-2_4

Download citation

Publish with us

Policies and ethics