PHP code is usually processed on a web server by a PHP interpreter implemented as a module, a daemon or as a Common Gateway Interface (CGI) executable. On a web server, the result of the interpreted and executed PHP code – which may be any type of data, such as generated HTML or binary image data – would form the whole or part of an HTTP response. Various web template systems, web content management systems, and web frameworks exist which can be employed to orchestrate or facilitate the generation of that response. Additionally, PHP can be used for many programming tasks outside the web context, such as standalone graphical applications and robotic drone control. PHP code can also be directly executed from the command line.
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.
What distinguishes PHP from something like client-side JavaScript is that the code is executed on the server, generating HTML which is then sent to the client. The client would receive the results of running that script, but would not know what the underlying code was. You can even configure your web server to process all your HTML files with PHP, and then there's really no way that users can tell what you have up your sleeve.
A PHP script can be placed anywhere in the document. A PHP script starts with <?php
and ends with
?>
:
PHP is particularly good at interacting with MySQL databases, which opens endless possibilities.
You can write user-submitted information to a database as well as retrieve information from the database. This allows you to create pages on the fly using the contents of the database.
You can even perform complex tasks like setting up a login system, create a website search feature, or keep your store's product catalog and inventory online. You can also use PHP and MySQL to set up an automated picture gallery to showcase products.