MENU
PHP
PHP runs on the server. Particularly, it can process forms, files and databases over the internet.To use PHP, you must first rent a server from a web host such as iPage, or set up your own server (Chapter 13). There are all-in-one packages that allow PHP to be run on a local computer, such as XAMPP and WampServer. These distributions contain Apache, PHP, MySQL and other applications.
| Usage of Server-Side Languages, 1 Sep 2026 | |
|---|---|
| PHP | 70.2% |
| JavaScript | 7.2% |
| Ruby | 7.0% |
| Java | 5.5% |
| Scala | 5.1% |
| ASP.NET | 4.2% |
| Static files | 2.1% |
| Python | 1.2% |
| ColdFusion | 0.2% |
| Perl | 0.1% |
| Others (<0.1% each): Haskell, Erlang, Miva Script, Smalltalk, C, C++, Lasso, Go, Tcl, Lisp, Basic, Lua, Ada |
|
| (Courtesy of https://w3techs.com/technologies/overview/programming_language) | |
This tutorial is kept current through PHP 8.5 — see Version Features for a recap of what each release since 5.6 added.
When a PHP file is requested from the server, the server first executes blocks of PHP code within the file. A ‘normal HTML file’ is then returned to the client’s browser. As such, there is no way for a casual visitor to read the PHP code. These blocks of code are contained by the symbols <?php … ?>:
The server, after replacing the PHP block with the output, returns a converted document to the browser. (echo and print output the value of an expression, and they can be used interchangeably.)
<!-- intro.php -->
<!DOCTYPE html>
<html>
<head></head>
<body><?php
echo "Hello ";
print "<b>World!</b>";
?>
</body>
</html>
Hello World!
<!-- introd.php -->
<!DOCTYPE html>
<html>
<head></head>
<body>
<?php
$expression=true;
if ($expression == true): ?>
This part will be shown.
<?php else: ?>
This part will not be shown.
<?php endif; ?>
</body>
</html>
This part will be shown.