PHP, Hypertext Preprocessor is a scripting language that Javascript developers love to shit on. PHP was originally built by Rasmus Lerdorf a Danish-Canadian 10x developer.
PHP the abbreviation gives you an insight into what you should expect with this one. It was originally "Personal Home Page" but now PHP stands for "PHP, Hypertext Preprocessor". The PHP language evolved without a written formal specification or standard until 2014. Early PHP was not intended to be a new programming language, and this is in quote from the guy who built PHP "There was never any intent to write a programming language, I have no idea how to write a programming language". This is where it all started.
PHP is weakly typed and supports dynamic typing, something we are quite familiar with in Javascript, and makes learning PHP considerably easy. PHP is object-oriented and supports popular object-oriented concepts. It also has room for Functional Programming and supports higher-order functions.
PHP can run on Windows, Linux, and MacOS, it runs on the server and it's currently used to power over 77.8% of websites. However, only 7.8% of the websites running on PHP are Using the latest iteration of PHP which is PHP8 while 23% of strong-hearted teams use PHP 5, which is not supported with security fixes and is known to have serious security vulnerabilities. I need to work more on my trust issues.
PHP is currently being maintained by three organizations; PHP Development Team, Zend Technologies, and PHP Foundation. The development of PHP originally started in 1993. The creator of PHP compiled the CGI scripts he used to maintain his website, extended them to interact with databases and process web forms, and named it "Personal Home Page/Forms Interpreter" or PHP/FI." Since then there has been 6 major PHP release with version 8 being the last Major release of PHP.
PHP has a cool mascot, the only thing I like about PHP, just kidding PHP might be an inconsistent programming language but that doesn't mean it's totally ugly. PHP has some awesome constructs like you can declare a destructor function for your objects, and PHP has a nice forEach loop syntax. Then there's the match expression which is quite similar to the switch expression. PHP also allows you to handle your errors gracefully, you can use the assert function or use the throw syntax to throw an Error, and supports arrow functions
Declaring a variable is super easy, there's no keyword you just prefix the variable with the $ and you have to use a semicolon after each line in PHP because semicolons are expression terminators, PHP is weekly typed and supports a range of different data types by default. PHP has support for integers and floating point numbers, booleans, strings, and Arrays. Talking about arrays there are two types of arrays in PHP associative arrays and non associative arrays. You can also specify types for function parameters and PHP will throw an error if the incorrect type is passed in.
PHP is a strong object-oriented language, there's support for classes, abstract classes, and abstract methods, allowing you to utilize popular object-oriented programming patterns, PHP also supports interfaces and allows for multiple inheritance. Inside classes, you can declare public, private, protected, and Read-only properties. PHP has a garbage collector to help you manage memory in your code.
PHP simplifies database interaction, there's a PDO object that allows you to interact with MySQL or another relational database. This PDO supports both functional and object-oriented approaches, however, be prepared to write a lot of SQL code by hand. PHP also allows you to manipulate the file system, create folders, create and delete files, and read and write to files.
PHP can also be used to generate dynamic content like broiler plate for your website and it's not limited to just HTML, PHP can be used to create XML, PDFs, and images on the fly. PHP excels at full-stack web development and it has some cool frameworks like Laravel and Symphony that can be used to build full-stack web applications and stand-alone APIs.
Symphony is a low-level library that gives you the components required to build your app how you want it. Laravel, on the other hand, is an opinionated framework and it's very cagey in the way it expects you to build your app. PHP also has a package manager called Composer. Some of the awesome companies using PHP include Facebook, yes the social media giant is built in PHP, and WordPress which powers 65.2% of all websites built in PHP, your favorite internet encyclopedia Wikipedia is also written in PHP.
To get started with PHP visit the PHP website, and download and install the latest version of PHP, alternatively, you could download and install XAMPP, and boot up your PHP server. create a file and save it with a .php extension.
Thank you for your time and I'll see you in the next one.