Getting Started with PHP – What is PHP?
In this economic climate, it’s not unlikely that your desire to learn PHP is to add to your skill set and make your resume stand out better when it comes across your next potential employer’s desk. Interestingly enough, Rasmus Lerdorf, the original creator of “Personal Home Pages”, or ‘PHP’, created the language to help track visitors to a page that showcase… you guessed it… his resume.
PHP has come a long way since then and is currently in its 5th installment, and the PHP now stands for ‘PHP: Hypertext Preprocessor”. So, what is PHP and how is it different from other languages like the HTML and CSS you already know?
Well, even though PHP is embedded in your HTML – we’ll discuss this later – it isn’t a markup language in the same sense as HTML or CSS. PHP is a scripting language. If you’ve ever seen PHP code, you might think it looks more like a programming language.
In reality, PHP does derive some of its structure from programming language influences and, sure, it has all the signs of a programming language – variables and loops and arrays, oh my – but it’s important to remember that PHP can only take action when you do. For example, when your user fills out a form on your site, they must press submit before PHP can get involved.
Scripting languages rely on action – so, PHP can only be used when it is called to the front lines. You may have heard of other scripting languages like Javascript, but there is one major difference between Javascript and other scripting languages like PHP.
PHP is what we call a ‘server-side’ scripting language; conversely, Javascript is considered a ‘client-side’ scripting language. When you visit a webpage, your machine sends out a request for that page and the server that holds the page sends back the information you requested. When a script is involved, it needs to get itself into the timeline somewhere.
A ‘client-side’ script, like a Javascript, is referred to as such because it waits until the information has been received by the user, or ‘client’, and then executes inside of the browser. A ‘server-side’ script, like PHP, executes a little earlier in the timeline. After the server receives the request for the page, but before it sends it back to the user, the PHP is processed by the server and the result of the script is what is sent back to the user.
The difference is that, if your user doesn’t have Javascript, then any feature of your site that relies on it will be disabled on that user’s computer. On the other hand, a ‘server-side’ script, since it doesn’t rely on any special conditions to be provided by your user, always executes.
By now, we have an understanding of the nature of PHP, but if you are unfamiliar with scripting languages in general, you may not understand why we would want to work with this in the first place. PHP and other scripting languages are used because they can help us create ‘dynamic’ webpages.
When websites are ‘static’ they do not provide any opportunities to interact or influence the page. Think about your favorite website. Can you post comments in response to articles or post photos or log-in to your account to check your order status? These pages, and more and more pages everyday, are becoming ‘dynamic’, meaning that each page is created specially for the person that is using it. You may see slightly different pages than your neighbor or your brother down the street.
PHP can help you create similar pages by allowing information to move in and out of your webpage. Pretend you run a retail website and your customer comes to you site after making a purchase. They’d like to purchase the same thing they purchased before, but don’t remember the name of the product. They log-in to their account and check their order history – if you are wise, you would have already placed a ‘Reorder’ button next to the item…
In both of these scenarios, PHP has created dynamic pages – that is, they are the same basic pages for everyone – myaccount.php and orderhistory.asp – but, in each case, PHP pulls in information specific to that individual customer and they see a web page that no other visitor will see. Additionally, PHP has been used for the log-in page as well – showing everyone the same basic log-in page – login.php – but then using the information entered to ensure that the person at home is the right person who should be accessing this account information.
This dynamic nature of PHP allows it to work with almost any scenario in which you need to take in certain information, evaluate it, and then return a response. It could be as simple as an email form that allows customers to give you feedback. PHP will take their comments and put them in an email. Do you receive too many comments to keep track of? PHP can collect them and send you one email with all the days comments, or just keep track of them so that you can view and access them as you want.
PHP can also handle more complicated tasks, as when it is used in Content Management Systems. (An aside – when we talk about content management systems, or what is commonly referred to as a CMS, we are talking about any system that allows you to make changes or updates to a website without directly editing or modifying code).
For example, I am currently working on a script written entirely in PHP that pulls information in from a client’s Yahoo webstore, reads, collects, and rearranges that data, and then outputs the same information in the format that Amazon prefers so that the client can easily take their existing product catalog and add it to additional marketplaces.
Let’s clear up a few more details regarding the ‘what’ of PHP. PHP has its own website! Located at php.net, the official page of PHP has tutorials and a complete manual that is always a key reference when debugging a script or learning new functions. On their site, to answer the question of ‘What is PHP?’, they say, ‘PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.
There it is again – ‘embedded’ into HTML. What does this mean? PHP does not standalone – it works with HTML. So, when you are creating a page, you may code in your headers and navigation the same as always. Maybe the part of your web page where you would like to use PHP doesn’t come in until the user is two-thirds down the page. Not a problem! PHP can be embedded, or placed within, your HTML code.
In Part 3 of this series, when we write our first PHP script, we will see that, in order to do this, we must use special HTML tags to tell the page where the PHP is, and we must also change the extension from .html to .php – this is the way we tell the server that there is some PHP in the page that it needs to process before it sends the page to the user.
I mention this now because it is now very easy for you to see when PHP has been used in a page. Now, since PHP is processed before it reaches your computer, you will not be able to see it when you view the page source, but, all you have to do is look up at your address bar. If the page address ends with .php, such as ‘https://www.thispage.com/info/page2.php’ then you know that page has some PHP in it!
It’s also important to remember that PHP is cross-platform – meaning that it will work equally well on both PCs and Macs.
We now know the ‘what’, but ‘why’ PHP? Use PHP because it was designed to do just this – create dynamic web pages, and do it well. Other web professionals might recommend other similar languages to you, such as ASP. There are reasons to use PHP instead of ASP and the issue of one over the other has been hotly debated for some time now.
In general, languages such as ASP require the use of other languages that were not designed directly for dynamic web pages. In the case of ASP, we’re looking at VBScript. So, to really be effective with ASP, you also need to know some VBScript. Another advantage is that, since PHP was created for this purpose, it tends to be faster and more efficient in its processing. But, really, what’s the best reason? PHP is open source. This means it is free. Free. ASP is not. ASP really isn’t free.
How do I get started?
Good question! Head on over to Part 2 (coming soon!) of this Getting Started series and we’ll talk about how you can get PHP to run on your machine so you can start writing all the scripts you’d like!
Thanks for reading.
-Matt
PHP Editor
PHP has come a long way since then and is currently in its 5th installment, and the PHP now stands for ‘PHP: Hypertext Preprocessor”. So, what is PHP and how is it different from other languages like the HTML and CSS you already know?
Well, even though PHP is embedded in your HTML – we’ll discuss this later – it isn’t a markup language in the same sense as HTML or CSS. PHP is a scripting language. If you’ve ever seen PHP code, you might think it looks more like a programming language.
In reality, PHP does derive some of its structure from programming language influences and, sure, it has all the signs of a programming language – variables and loops and arrays, oh my – but it’s important to remember that PHP can only take action when you do. For example, when your user fills out a form on your site, they must press submit before PHP can get involved.
Scripting languages rely on action – so, PHP can only be used when it is called to the front lines. You may have heard of other scripting languages like Javascript, but there is one major difference between Javascript and other scripting languages like PHP.
PHP is what we call a ‘server-side’ scripting language; conversely, Javascript is considered a ‘client-side’ scripting language. When you visit a webpage, your machine sends out a request for that page and the server that holds the page sends back the information you requested. When a script is involved, it needs to get itself into the timeline somewhere.
A ‘client-side’ script, like a Javascript, is referred to as such because it waits until the information has been received by the user, or ‘client’, and then executes inside of the browser. A ‘server-side’ script, like PHP, executes a little earlier in the timeline. After the server receives the request for the page, but before it sends it back to the user, the PHP is processed by the server and the result of the script is what is sent back to the user.
The difference is that, if your user doesn’t have Javascript, then any feature of your site that relies on it will be disabled on that user’s computer. On the other hand, a ‘server-side’ script, since it doesn’t rely on any special conditions to be provided by your user, always executes.
By now, we have an understanding of the nature of PHP, but if you are unfamiliar with scripting languages in general, you may not understand why we would want to work with this in the first place. PHP and other scripting languages are used because they can help us create ‘dynamic’ webpages.
When websites are ‘static’ they do not provide any opportunities to interact or influence the page. Think about your favorite website. Can you post comments in response to articles or post photos or log-in to your account to check your order status? These pages, and more and more pages everyday, are becoming ‘dynamic’, meaning that each page is created specially for the person that is using it. You may see slightly different pages than your neighbor or your brother down the street.
PHP can help you create similar pages by allowing information to move in and out of your webpage. Pretend you run a retail website and your customer comes to you site after making a purchase. They’d like to purchase the same thing they purchased before, but don’t remember the name of the product. They log-in to their account and check their order history – if you are wise, you would have already placed a ‘Reorder’ button next to the item…
In both of these scenarios, PHP has created dynamic pages – that is, they are the same basic pages for everyone – myaccount.php and orderhistory.asp – but, in each case, PHP pulls in information specific to that individual customer and they see a web page that no other visitor will see. Additionally, PHP has been used for the log-in page as well – showing everyone the same basic log-in page – login.php – but then using the information entered to ensure that the person at home is the right person who should be accessing this account information.
This dynamic nature of PHP allows it to work with almost any scenario in which you need to take in certain information, evaluate it, and then return a response. It could be as simple as an email form that allows customers to give you feedback. PHP will take their comments and put them in an email. Do you receive too many comments to keep track of? PHP can collect them and send you one email with all the days comments, or just keep track of them so that you can view and access them as you want.
PHP can also handle more complicated tasks, as when it is used in Content Management Systems. (An aside – when we talk about content management systems, or what is commonly referred to as a CMS, we are talking about any system that allows you to make changes or updates to a website without directly editing or modifying code).
For example, I am currently working on a script written entirely in PHP that pulls information in from a client’s Yahoo webstore, reads, collects, and rearranges that data, and then outputs the same information in the format that Amazon prefers so that the client can easily take their existing product catalog and add it to additional marketplaces.
Let’s clear up a few more details regarding the ‘what’ of PHP. PHP has its own website! Located at php.net, the official page of PHP has tutorials and a complete manual that is always a key reference when debugging a script or learning new functions. On their site, to answer the question of ‘What is PHP?’, they say, ‘PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.
There it is again – ‘embedded’ into HTML. What does this mean? PHP does not standalone – it works with HTML. So, when you are creating a page, you may code in your headers and navigation the same as always. Maybe the part of your web page where you would like to use PHP doesn’t come in until the user is two-thirds down the page. Not a problem! PHP can be embedded, or placed within, your HTML code.
In Part 3 of this series, when we write our first PHP script, we will see that, in order to do this, we must use special HTML tags to tell the page where the PHP is, and we must also change the extension from .html to .php – this is the way we tell the server that there is some PHP in the page that it needs to process before it sends the page to the user.
I mention this now because it is now very easy for you to see when PHP has been used in a page. Now, since PHP is processed before it reaches your computer, you will not be able to see it when you view the page source, but, all you have to do is look up at your address bar. If the page address ends with .php, such as ‘https://www.thispage.com/info/page2.php’ then you know that page has some PHP in it!
It’s also important to remember that PHP is cross-platform – meaning that it will work equally well on both PCs and Macs.
We now know the ‘what’, but ‘why’ PHP? Use PHP because it was designed to do just this – create dynamic web pages, and do it well. Other web professionals might recommend other similar languages to you, such as ASP. There are reasons to use PHP instead of ASP and the issue of one over the other has been hotly debated for some time now.
In general, languages such as ASP require the use of other languages that were not designed directly for dynamic web pages. In the case of ASP, we’re looking at VBScript. So, to really be effective with ASP, you also need to know some VBScript. Another advantage is that, since PHP was created for this purpose, it tends to be faster and more efficient in its processing. But, really, what’s the best reason? PHP is open source. This means it is free. Free. ASP is not. ASP really isn’t free.
How do I get started?
Good question! Head on over to Part 2 (coming soon!) of this Getting Started series and we’ll talk about how you can get PHP to run on your machine so you can start writing all the scripts you’d like!
Thanks for reading.
-Matt
PHP Editor
This site needs an editor - click to learn more!
Related Articles
Editor's Picks Articles
Top Ten Articles
Previous Features
Site Map
Content copyright © 2023 by Matt Swan. All rights reserved.
This content was written by Matt Swan. If you wish to use this content in any manner, you need written permission. Contact
BellaOnline Administration
for details.