Professional Documents
Culture Documents
New Chapter
New Chapter
New Chapter
Intro..
Php
● It has been used to build many CMS (Content Management System) like
WordPress, Drupal, Shopify, WooCommerce etc.
Features
● Open-source
● Easy to use ( C-like and Perl-like syntax)
● Stable and fast
● Multiplatform Support
● Supports various databases
● Many common built-in libraries
Conti…
● Cost efficient
● Platform independent
● It is an interpreted language
● Help from community
Who uses php ?
● Facebook
● Wikipedia
● Tumblr
● Slack
● MailChimp
● Etsy
● WordPress
How page request works :
<!DOCTYPE html>
<html>
<head>
<title>PHP!</title>
</head>
<body>
<p>
<?php echo "Hello world!"; ?>
</p>
</body>
</html>
Or you can…
<?php
header("Content-Type: text/plain");
echo "Hello World";
?>
Some uses
● PHP can handle forms, i.e. gather data from files, save data to a file, thru
email
● you can send data, return data to the user.
● You add, delete, modify elements within your database thru PHP.
Variables
● No declaration required.
● A new variable is created & gets stored when we assign a value to it.
● eg $text = “Hello World”;
● The above statement will create a new variable and assign the string
value ‘hello world’ to it, at the same time.
● echo ‘this is $text’;
● echo ‘this is’.$text.’only’;
● Both the above statements work the same.
Accessing input tags
<form method="get">
<input type=“text” name=“user”>
</form>
<?php
echo $_GET[“user"];
?>
Program Flow Control
If(condition)
{
logic;
}
Program Flow Control
● If
● If-else
● If-elseif
● If-elseif-else
● switch
● for loop
● foreach loop
● while loop
● do-while loop
● break
● continue
Example
● Create calc