What Is PHP And Why Should You Know About It?
If you’ve ever sat in a room with people designing web pages and heard the terms HTML and PhP, you may have wondered what people were discussing.
If you have some familiarity with HTML, you can look at the following image and pull out familiar HTML framings:
In this particular text, you can notice, at the top, a reference to php, and then right after, a more familiar html tag–<div id=”…>
Why? The easiest answer? Some web sites store the lion share of the content in a data base while other web sites are based on a set of pages designed using HTML and CSS.
If you’re designing a web site, here’s the fundamental question you want to ask yourself:
How much content will be on the site; will the content change often? If the answer to the first question is more than the equivalent of 10 pages and 10k words, you probably want to turn to a content management system which relies on a database for the content, and the use of php to access stored content in a database.
One of the more user-friendly server-side scripting languages, PHP offers web builders and designers the ability to create dynamic sites, features, and forms. PHP is also an interface between a server-side database and a client-side browser. Originally abbreviated for “Personal Home Page,” PHP is now a recursive backronym for “Hypertext Preprocessor.”
In order to fully grasp what PHP is and how it can be used, the reader/user is expected to have a fundamental knowledge of the terminology, programming, and concepts used – as they relate to scripting language. Below are some quick explanations/definitions for terms that many web sites use in order to explain how PhP works.
Think Google Chrome, Firefox, Safari. A web browser is what users view the webpage or program through.
A client, for purposes of this article, is any person who accesses a website. Thus, client-side scripting is HTML and other source coding that can be viewed, accessed, and edited on a users (or clients) computer, rather than a database stored restrictively on a server. PHP is considered server-side scripting since it uses a CGI and thus processes HTML and source codes on the server side, hidden away from the client.
Common gateway interface (CGI)
A CGI is any program designed to accept and return data that conforms to specific CGI specifications (Vidya). They are the “most common way for web servers to interact dynamically with users” (Vidya) and have many capabilities: collect form data, generate dynamic page content, or send/receive cookies.
As mentioned in the introduction, PHP serves as an interface between a database and a browser. A link between servers, PHP provides a tunnel between server-side and client-side scripting. HTML creates a form and PHP uses the information from those forms. The information on the form contains certain values that are submitted and stored on a database for PHP. In plain English, this is the creation of a user-registration to log-in or register for a site. The fields are set to have a specific format with specific content (fields such as email, username, password, phone number, address, etc.) where specific criteria of characters should be used. When a user types in this information, it is sent via PHP to the database storing the information, where the PHP script is then checked to verify that the content entered meets the criteria for the user to sign in. This same function also allows users to change information previously stored on the database (i.e. changing your password).
PHP is used by some of the largest websites in the world – to include WordPress and Facebook.
In a series of instructional videos, Caleb Curry explains PHP in its entirety and the process it takes beginning with downloading the program to finishing a PHP project. Traditionally when using the computer, HTML is sent from the server to the computer, which is then displayed on the web browser (whether that be Google Chrome, Firefox, Safari, etc.). Even though PHP has hidden features not available on the client-side, PHP has the ability to write HTML so long as the HTML is contained outside of the PHP tags. When embedding with HTML, PHP code must be enclosed in its own opening and closing tags: . All of the content contained within the HTML and the PHP tags will be sent from the server-side to the client’s web browser. The only PHP content that will appear on the browser will be the to-be-displayed coded content. Otherwise, the source code and tags for PHP remains on the server-side and is unavailable for the client to view. The client, however, has access to the HTML source code with a right click of the mouse.