0% found this document useful (0 votes)
4 views

notes php intro

PHP (PHP: Hypertext Preprocessor) is a widely-used, open-source server-side scripting language designed for web development, allowing dynamic content creation and database interaction. PHP files, which have a .php extension, can include HTML, CSS, JavaScript, and PHP code, and are executed on the server to generate HTML output. Key features of PHP include its simplicity, efficiency, and flexibility, making it suitable for a variety of applications such as form handling, database management, and user access control.

Uploaded by

preeti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

notes php intro

PHP (PHP: Hypertext Preprocessor) is a widely-used, open-source server-side scripting language designed for web development, allowing dynamic content creation and database interaction. PHP files, which have a .php extension, can include HTML, CSS, JavaScript, and PHP code, and are executed on the server to generate HTML output. Key features of PHP include its simplicity, efficiency, and flexibility, making it suitable for a variety of applications such as form handling, database management, and user access control.

Uploaded by

preeti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

The PHP Hypertext Preprocessor (PHP) is a programming language that allows web developers to create

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 is a recursive acronym for "PHP: Hypertext Preprocessor".


 PHP is a server side scripting language that is embedded in
HTML. It is used to manage dynamic content, databases,
session tracking, even build entire e-commerce sites.
 It is integrated with a number of popular databases, including
MySQL, PostgreSQL, Oracle, Sybase, Informix, and Microsoft
SQL Server.

What is a PHP File?


 PHP files can contain text, HTML, CSS, JavaScript, and PHP code
 PHP code is executed on the server, and the result is returned to the
browser as plain HTML
 PHP files have extension ".php"

What Can PHP Do?


 PHP can generate dynamic page content
 PHP can create, open, read, write, delete, and close files on the server
 PHP can collect form data
 PHP can send and receive cookies
 PHP can add, delete, modify data in your database
 PHP can be used to control user-access
 PHP can encrypt data

PHP Syntax
❮ PreviousNext ❯
A PHP script is executed on the server, and the plain HTML result is sent back
to the browser.

Basic PHP Syntax


A PHP script can be placed anywhere in the document.

A PHP script starts with <?php and ends with ?>:

<?php

// PHP code goes here

?>

The default file extension for PHP files is ".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:

ExampleGet your own PHP Server


A simple .php file with both HTML code and PHP code:

<!DOCTYPE html>

<html>

<body>

<h1>My first PHP page</h1>

<?php

echo "Hello World!";


?>

</body>

</html>

Try it Yourself »

Note: PHP statements end with a semicolon (;).

PHP Case Sensitivity


In PHP, keywords (e.g. if, else, while, echo, etc.), classes, functions, and user-
defined functions are not case-sensitive.

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

ECHO "Hello World!<br>";

echo "Hello World!<br>";

EcHo "Hello World!<br>";

?>

</body>

</html>
Try it Yourself »

Note: However; all variable names are case-sensitive!

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";

echo "My car is " . $color . "<br>";

echo "My house is " . $COLOR . "<br>";

echo "My boat is " . $coLOR . "<br>";

?>

</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:

 PHP performs system functions, i.e. from files on a system it


can create, open, read, write, and close them.
 PHP can handle forms, i.e. gather data from files, save data to
a file, through email you can send data, return data to the
user.
 You add, delete, modify elements within your database
through PHP.
 Access cookies variables and set cookies.
 Using PHP, you can restrict users to access some pages of your
website.
 It can encrypt data.
PHP - Environment Setup
In order to develop and run PHP Web pages three vital components
need to be installed on your computer system.

 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.

PHP Parser Installation


Before you proceed it is important to make sure that you have
proper environment setup on your machine to develop your web
programs using PHP.

Type the following address into your browser's address box.

http://127.0.0.1/info.php

If this displays a page showing your PHP installation related


information then it means you have PHP and Webserver installed
properly. Otherwise you have to follow given procedure to install
PHP on your computer.

This section will guide you to install and configure PHP over the
following four platforms −

 PHP Installation on Linux or Unix with Apache


 PHP Installation on Mac OS X with Apache
 PHP Installation on Windows NT/2000/XP with IIS
 PHP Installation on Windows NT/2000/XP with Apache
Apache Configuration

If you are using Apache as a Web Server then this section will guide
you to edit Apache Configuration Files.

Just Check it here − PHP Configuration in Apache Server


PHP.INI File Configuration

The PHP configuration file, php.ini, is the final and most immediate
way to affect PHP's functionality.

Just Check it here − PHP.INI File Configuration


Windows IIS Configuration

To configure IIS on your Windows machine you can refer your IIS
Reference Manual shipped along with IIS.

You might also like