What exactly is PHP?

PHP (hypertext preprocessor) is a widely-used open source general-purpose scripting language suitable for web development and can be embedded in HTML.

That’s nice, but what exactly does that imply? Consider the following scenario:

The first example is a simple one.

!DOCTYPE html> html> html> html> html> html> html> html> html> html> html> html> html> html> html

/head> /body> /title> /head> /body> /title> /head> /body> /head

PHP echo “Hello, I’m a PHP script!”; PHP echo “Hello, I’m a PHP script!”; PHP echo “Hello, I’m a PHP script!”

</body> \s</html>

Syntax

PHP pages contain HTML with embedded code that performs “something” (in this example, print “Hi, I’m a PHP script!”) instead of a long list of commands to produce HTML (like in C or Perl). The PHP code is encased between specific start and end processing instructions?PHP and?> that enable you to switch between “PHP mode” and “normal mode.”

PHP is distinguished from client-side JavaScript because the code is performed on the server, resulting in HTML that is then provided to the client. The client would receive the results of the script’s execution but would not be aware of the underlying code. You may even set up your webserver to process your HTML files with PHP, making it virtually impossible for people to figure out what you’re up to.

Advantages

The nicest thing about PHP is that it is very easy to learn for a beginner, but it has a lot of complex capabilities for a skilled programmer. Don’t be frightened to browse through PHP’s extensive feature list. You can hop right in and begin developing simple scripts in hours.

Although PHP was designed with server-side scripting in mind, it is capable of much more. Continue reading to learn more about what PHP can achieve, or skip straight to the beginning course if you’re solely interested in web development.