What is PHP?
PHP is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.
Nice, but what does that mean?
Instead of lots of commands to output HTML, PHP pages contain HTML with embedded code that does something. The PHP code is enclosed in special start and end processing instructions that allow you to jump into and out of “PHP mode.”
PHP Date Formatting
To have the current date or time displayed through PHP, specific characters are required for particular elements. This means a lowercase ‘d’ represents a day of the month displayed as 2 digits which can range from 01-31. An uppercase ‘M’ represents the month displayed as text in short-form (Jan, Jul, Nov). An uppercase ‘Y’ represents a year displayed as four digits (2017, 2020, 2025). To display the date; 25 Dec 2017 you would write
echo date("d M Y"); in your php code.
Punctuation is also important in PHP date formatting. If you wanted to display 03.01.18 you would write
echo date("d.m.y"); ensuring you include the ‘.’ in your PHP code. You can find the full list of characters here.
- Simple. PHP is simple for a newcomer, especially if they have experience in HTML.
- Open Source. PHP is Open Source, meaning it is developed and maintained by a large group of PHP Developers that help create a support community.
- Speed. PHP is relatively fast.
- Stable. PHP is very stable because since it is maintained by many developers, when a problem is found, it can be quickly fixed.
- Security. Since PHP is open sourced, people can look for bugs in the source code to find it’s weaknesses.
- Large Applications. PHP is not suitable for large applications and they can be difficult to maintain.
HTML vs PHP
- HTML is a Markup Language, PHP is a Scripting Language.
- HTML is used to create Static pages, PHP is used to create Dynamic ones.
- HTML is a mainly Front-End technology whereas PHP is mainly Back-End.