notes php intro
notes php intro
dynamic content that interacts with databases. PHP is basically used for developing web based software
applications.
What is PHP?
PHP is an acronym for "PHP: Hypertext Preprocessor"
PHP is a widely-used, open source scripting language
PHP scripts are executed on the server
PHP is free to download and use
PHP Syntax
❮ PreviousNext ❯
A PHP script is executed on the server, and the plain HTML result is sent back
to the browser.
<?php
?>
A PHP file normally contains HTML tags, and some PHP scripting code.
Below, we have an example of a simple PHP file, with a PHP script that uses a
built-in PHP function "echo" to output the text "Hello World!" on a web page:
<!DOCTYPE html>
<html>
<body>
<?php
</body>
</html>
Try it Yourself »
In the example below, all three echo statements below are equal and legal:
Example
ECHO is the same as echo:
<!DOCTYPE html>
<html>
<body>
<?php
?>
</body>
</html>
Try it Yourself »
Look at the example below; only the first statement will display the value of
the $color variable! This is because $color, $COLOR, and $coLOR are treated as
three different variables:
Example
$COLOR is not same as $color:
<!DOCTYPE html>
<html>
<body>
<?php
$color = "red";
?>
</body>
</html>
Try it Yourself »
Characteristics of PHP
Five important characteristics make PHP's practical nature possible
−
Simplicity
Efficiency
Security
Flexibility
Familiarity
Hello World using PHP.
Just to give you a little excitement about PHP, I'm going to give
you a small conventional PHP Hello World program, You can try
it using Demo link.
Live Demo
<html>
<head>
<title>Hello World</title>
</head>
<body>
<?php echo "Hello, World!";?>
</body>
</html>
Applications of PHP
As mentioned before, PHP is one of the most widely used language
over the web. I'm going to list few of them here:
Web Server − PHP will work with virtually all Web Server
software, including Microsoft's Internet Information Server (IIS)
but then most often used is freely available Apache Server.
Download Apache for free here
− https://httpd.apache.org/download.cgi
Database − PHP will work with virtually all database software,
including Oracle and Sybase but most commonly used is freely
available MySQL database. Download MySQL for free here
− https://www.mysql.com/downloads/
PHP Parser − In order to process PHP script instructions a
parser must be installed to generate HTML output that can be
sent to the Web Browser. This tutorial will guide you how to
install PHP parser on your computer.
http://127.0.0.1/info.php
This section will guide you to install and configure PHP over the
following four platforms −
If you are using Apache as a Web Server then this section will guide
you to edit Apache Configuration Files.
The PHP configuration file, php.ini, is the final and most immediate
way to affect PHP's functionality.
To configure IIS on your Windows machine you can refer your IIS
Reference Manual shipped along with IIS.