Software, your way.
How To Get Good Custom Software
(Download)
(PDF)
burger menu icon
WillMaster

WillMaster > LibraryTutorials and Answers

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

How PHP Works

When you understand this article, you will have an intuitive understanding of what PHP is and a better grasp of what is possible to do with it.

You already understand that when you surf the internet your browser gets web pages from other computers. These computers are called servers.

You click on one of a selection of links or type a URL into your browser's address bar and your browser requests that web page from a server. The web page is then sent to your browser, where you can view it.

Let's compare the process to ordering a home entertainment system over the telephone. You have the catalog open in front of you and you tell the server (the order person you're talking to) which model you want. Your order gets sent to your home, where you can use it.

Most home entertainment system catalogs have systems pre-configured for immediate delivery. These are listed in the catalog with product IDs. Everybody who orders the same product ID from the catalog is sent an identical system.

Most servers have web pages ready to be sent to the browser as is. These are static web pages. Every browser that requests a specific static web page is sent an identical page.

Some home entertainment system catalog companies allow customers to custom configure entertainment systems. Configuration options determine what can and can not be configured.

Customers provide the configuration information when they order. The company then constructs each requested system accordingly and sends it to the customer.

Some servers have web pages that can be customized. PHP in the web page source code determines how the customizations shall be done.

Browsers provide customization information with cookies, or by other means, like providing the URL of the web page where the link was clicked or the identification of the browser itself. The server then customizes each requested web page accordingly and sends it to the browser.

Some home entertainment system catalog companies customize their products according to, as examples, customer demographics, whether or not it is a repeat customer, how much the customer has previously spent, the customer's marital status, or in response to market changes in music or video.

PHP code in a web page can customize the contents according to, as examples, time of day, IP address of the browser, how many other pages have already been viewed, the general speed of the Internet, how busy the servers are, or in response to upcoming holidays or world events.

All PHP customizations are completed by the server before sending the web page to the browser. The web page sent to the browser does not contain the PHP code, as the code has already accomplished it's purpose.

PHP can cause a part of the web page to be different depending on the browser or even the individual visitor. It might insert a special message when the visitor arrives from a search engine, for example, or otherwise an invitation to take a survey.

PHP can utilize any data and software it can access on the server to custom-build a web page for your site visitors, in the format they find most pleasing. In some cases, the PHP code might also access data and software on other servers.

Services that provide personal portal pages are a good example. The blog synopses you prefer to keep up to date with are on the page. The weather widget displays the weather for the area you're interested in. The news headlines all pertain to the subjects you previously asked for. Your own picture, or that of a loved one or a hero can be on the page.

The web page content, the formatting, the colors, and even the placement of the various sections can reflect your personal preferences within the range of what the server has to offer.

PHP has within its power the ability to let you deliver personalization even to that degree for your own site visitors.

Individual visitor preferences can be kept in a database on the server. A cookie with the visitor's browser can contain a record number or other index to the data record.

When the visitor arrives at your website and the browser asks the server for a web page, the cookie tells the PHP code which data record the visitor's preferences are stored in. The web page is created accordingly and then sent to the browser.

PHP can do a lot of other things, also. For example, it can create images and PDF documents on-the-fly, maintain databases, talk to other servers, and compress files. It can compose and send email, log visitor activity, and accomplish many other tasks.

So, how about a real-world example?

Snoop-a-page was originally designed to determine what kind of server software is in use where a domain is hosted.

When you load Snoop-a-page, it asks for the URL of a web page on the server being snooped. When you click the button, the PHP code:

  1. Retrieves the web page at the URL you provided.

  2. Extracts the header portion of the web page it retrieved from the web page's content.

  3. Inserts the header portion into the Snoop-a-page web page.

  4. Sends the Snoop-a-page web page to your browser with the extracted header portion embedded in the content.

You end up at the same URL but with the extracted header portion embedded within it.

The header almost always identifies the software of the server a domain is hosted on. Sometimes, the identification includes version numbers.

The header also contains the response code (200 if all is okay, 404 if page not found, and so forth). And the header usually contains still more information, the content type and content length being two common ones.

With the overview you now have, you can better decide whether or not to pursue a greater understanding of PHP and, possibly, learn how to build PHP programs to do the tasks you want done.

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC