Last updated: April 12, 2021
What is PHP 5?
PHP is an interpreted language, or scripting language used to build dynamic websites and web applications. It has a long and storied history as the most popular language for web development, but it started as something quite a bit simpler.
Where did PHP start?
PHP started as a simple tool to help bring a bit of dynamic content into HTML files. This was way back in 1994, and it was called "Personal Home Page Tools" (PHP Tools). It was essentially a program written in C that let you embed variable content into HTML files.
This let you do things like this:
<h2><?php echo $post_title; ?></h2> <?php echo $post_content; ?>
This might seem pretty simple now, but back in 1994 it was a big deal. The internet was really still in its infancy, and most people were hand-coding every page of their website.
The idea took off, and pretty soon a handful of "personal home page tools" became the PHP language. Eventually, the name was recursively-backronymed to "PHP Hypertext Preprocessor."
Since then it has had several major rewrites and releases, lots and lots of new features added, and has become one of the most popular languages for web development. It is estimated that around 40% of websites are running at least some PHP code.
What is PHP exactly?
It's a programming language. It's an interpreted language, which means that PHP code isn't compiled into a binary executable, but rather is interpreted at run-time.
This sort of language is also called a "scripting language", and some people refer to programs written in these types of languages as "scripts" rather than "programs".
It is still focused on the web but is capable of doing a lot more than passing content variables into an HTML template. It is a full-scale language and can accomplish just about anything that any other language can do.
Why is PHP so popular?
Many people consider PHP very easy to read and write. For example, Mark Zuckerberg has said that one of the reasons Facebook uses PHP is that it is easy to get stuff done in PHP - it is "good for hacking on."
On the other hand, proponents of other languages say similar things. A more likely explanation of its widespread use is WordPress.
WordPress is a blogging and content management system. It powers over 23% of the websites on the internet.
A lot of PHP developers got their start using WordPress, and it's easy to go from tweaking WordPress themes to writing plugins to building entire web applications.
The barrier to entry for PHP is fairly low, so a lot of people learn PHP. A lot of people learn it, so then a lot of projects get started using it.
PHP grows up
Early versions of PHP weren't a complete language and didn't support all the types of things you might normally want to do if you were building a web application. And there were performance issues.
That's what happens when you try to solve a specific problem. It takes a while to turn a specific solution into a generalized toolset, and even longer to turn it into a complete toolset.
But eventually it happened.
In 2004, PHP 5 was released. With PHP 5, many people believe that the language was now really, truly, a programming language in the full sense of the term.
The biggest change in PHP 5 was support for Object-Oriented Programming.
PHP 5 and Object-Oriented Programming
Object-Oriented Programming (OOP) is a way of conceptualizing and writing a program in which data objects contain both attributes and methods for interacting with those attributes, as well as with other objects.
An example of this in web development is a blog post. The attributes of a blog post might be its title, author, content, and so forth. Methods might include saving it to the database, editing its content, and displaying it on the page.
Even though OOP was invented in the 1960s, it didn't become mainstream for most programmers and programming languages until the mid-1990s. When PHP was invented, OOP was still a pretty new idea.
Ten years later, after four major version releases of PHP, object-oriented programming had become "the right way" to write software, and the minimal support for OOP concepts in PHP 4 just wasn't enough.
PHP 5 provided complete support for Object Orientation, along with a number of other improvements that really changed the way people write PHP programs and allowed it to compete with other languages that had started to dominate 'serious' web development.
Looking for a great deal on quality PHP 5 hosting?
A2 Hosting came in #1 in our recent speed and performance tests. You can choose from multiple PHP versions with unlimited SSD storage and transfer. Use this special discount link to save up to 50% on these plans.
Closely related features
PHP 5 Frequently Asked Questions
- Is PHP 5 just for making websites?
No. PHP 5 can be used to build websites, command line scripting, or desktop GUI applications. The command line scripting can be used for tasks such as auto-generating offline images or processing text files. Unlike web-based PHP 5 applications, this does not require a browser or server. You simply need access to the command line executable. PHP 5 can be used to build desktop GUI applications similar to any other modern programming language; however, to do so you must first install the PHP-GTK extension.
- Since PHP 5 is a programming language, do I need any specific software to use it?
Yes. Most web hosts include support for PHP 5, but you can also download the latest version from the PHP website. If you're using PHP 5 to develop websites, you will need access to a modern browser and a website. If you are using PHP 5 to develop commend line applications or desktop applications, you won't need a browser or a server, but you may need additional extensions.
- Is PHP 5 compatible with PHP 4?
Yes. PHP 5 added several new features, but remains compatible with earlier versions. However, it is recommended that you review the documentation on PHP 5 migration available on the PHP website, as some functions may be lost when migrating from earlier versions.
- How can I report an issue with PHP 5?
If you identify an issue, you should review the bug database on the PHP website to make sure it is not already known. If the bug is not already on the database, you should use the reporting form available with the bug database.
- What databases does PHP 5 support?
PHP 5 was built to support a wide variety of databases, including SQLite, MySQL, MS-SQL, PostgreSQL, FrontBase, Mongo, Paradox, filePro, and more. It includes support for dBA, dbx, Open Database Connection standard, and PHP Data Objects.
- If I'm designing a website, do I need to choose either HTML or PHP?
No. PHP is an embedded script, meaning you can add it into an HTML script, provided your server supports PHP. A web-based PHP script is essentially an HTML page with bits of PHP inserted wherever dynamic content is required. You can also embed HTML code into PHP script.
- What functionality does PHP add to HTML?
PHP provides dynamic functionality for your webpage. It can perform calculations such as determining the date or handling mathematical equations. It can collect user input, such as obtaining an imperial measurement to convert it to metric, adding information to an address book, or letting users post to a forum or social media site. PHP can interact with most common databases, and it can be used to create graphics.
- Are there alternatives available that provide the same functionality as PHP?
While you won't get the exact same functionality from any one program, many of the features PHP adds to web development can be obtained through other sources. PHP was built on other programming languages, including C, so C can be used in place of PHP. Perl was one of the most popular languages for web development prior to PHP. While its syntax is considerably more complex than PHP, it continues to be popular with some developers due to its string manipulation capabilities. The Seaside framework provides the same dynamic functionality with object oriented web development.