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, 15 Nov 2014 | |
PHP | 82.0% |
ASP.NET | 17.3% |
Java | 2.7% |
ColdFusion | 0.7% |
Perl | 0.6% |
Ruby | 0.5% |
Python | 0.2% |
JavaScript | 0.1% |
Erlang | 0.1% |
Others (<0.1% each): Lasso, Scala, Tcl, Smalltalk, C++, Haskell, Lisp, Ada |
|
(Courtesy of http://w3techs.com/technologies/overview/programming_language/all) |
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.)
RESETRUNFULL
RESETRUNFULL
<!-- intro.php -->
<!DOCTYPE html>
<html>
<head></head>
<body><?php
echo "Hello ";
print "<b>World!</b>";
?>
</body>
</html>
<!-- intro.php -->
<!DOCTYPE html>
<html>
<head></head>
<body>Hello <b>World!</b></body>
</html>
<!-- One can choose to return only certain parts of the document: -->
RESETRUNFULL
<!-- 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>
<!-- introd.php -->
<!DOCTYPE html>
<html>
<head></head>
<body>
This part will be shown.
</body>
</html>