Introduction to PHP
What is PHP?
PHP is a server-side language. This means that all PHP code is interpreted and run on the webserver and not in the browser or client.
PHP is cross-platform, meaning that it can be used on web servers running on Unix, Windows, macOS, and other operating systems. It can also be moved from one platform to another with few or no modifications.
What PHP is Not?
Why use PHP?
Creating enticing and lasting websites cannot be done with HTML alone. Server-side technologies, like PHP, allow developers to create web applications that are dynamically generated that are often database-driven and can be updated and maintained easier and faster than static HTML pages.
There are other server-side technologies other than PHP, such as ASP.net, Java, Ruby, and Node.js. While these alternatives are very capable there are several reasons to learn PHP over these other languages:
- PHP is easier to learn and use
- PHP was written specifically for web page creation
- PHP is free and cross-platform
- PHP is the most popular tool for developing dynamic websites
How does PHP work?
PHP files reside on a web server that will serve up web pages to a browser. When you go to a website, your browser is directed to the web server that holds that website files. If the server sees that a PHP file was requested (PHP files end with .php instead of .html), then the server will request the PHP server to read the PHP code and process it according to its scripted directions. When the PHP server completes its interpretation of the PHP file, it sends back the web page data in the form of HTML. In other words, PHP creates HTML pages on the fly and the server sends that HTML code, and only the HTML code, to the browser.