PHP
Made by:Nupoor Garg
M-tech(CSE)

Professional Training Institute
BRIEF HISTORY
PHP FULL FORMS
DEFINITION

PHP is a server side scripting language that is
embedded in HTML. It is used to manage dynamic
content in your website.
WAMP SERVER
"Hello World" Script in
PHP
<HTML>

<HEAD>

<TITLE> First program <TITLE>

<BODY>

<BODY>

</HTML>

HELLO WORLD!

<?php

echo "Hello, World!";

</HEAD>
</BODY
?>
VARIABLES IN PHP
All variables are
declared with leading
dollar($) sign.

$vary=34;
$many=5.34;

Variable can, but do not
need to be declared
before assignment.

PHP does a good job of
automatically converting
types from one to
another when
necessary.

$sum=34;
$sum=“hiii”;
OPERATORS
Arithmetic Operators

Logical (or Relational) Operators

Assignment Operators

Conditional (or ternary) Operators
DATE FUNCTION IN PHP
• date(format)
EXAMPLE:DATE(

);

• Print date with time
EXAMPLE:DATE( “d-m-y h:m:s” );
Time zones
• To set the time zone
date_default_timezone_set();

• To get the time zone
date_default_timezone_get();
ARRAYS IN PHP
• Numeric array
An array with a numeric index. Values are stored and accessed in
linear fashion

• Associative array
An array with strings as index. This stores element values in
association with key values rather than in a strict linear index order.
Example (Numeric arrays)
• <?php
$cars=array("Volvo","BMW","Toyota");
• Echo “I like”.$cars[2];
• ?>
Example (associative array)
•
•
•
•
•
•
•
•
•
•

<html>
<body>
<?php
$salaries['mohammad'] = "high";
$salaries['qadir'] = "medium";
$salaries['zara'] = "low";
echo "Salary of qadir is ". $salaries['qadir']."<br/>";
?>
</body>
</html>
HEADER,INCLUDE AND
REQUIRE
• HEADER
IT IS USED TO REDIRECT TO ANOTHER PAGE.

• INCLUDE
IT IS USED TO INCLUDE THE ANOTHER PAGE INTO THE
CURRENT PAGE.

• REQUIRE
SAME AS INCLUDE.
STEP 1 :- TO ESTABLISH CONNECTION

mysql_connect(host,username,password,databasename);
<? PHP
$LINK=MYSQL_CONNECT(“LOCALHOST”,”ROOT”,””,”myd”);
IF($LINK)
{
ECHO “CONNECTION ESTABLISHED”
}
MYSQL BASIC QUERIES
• TO CREATE DATABASE
CREATE DATABASE DB_NAME;

• TO CREATE TABLE
CREATE TABLE TB_NAME(COL_NM1
DATATYPE,COL_NM2 DATATYPE……);

• TO LIST THE DATA
SELECT * FROM TABLE_NAME;
• TO INSERT VALUES IN TABLE
INSERT INTO TABLE_NAME
VALUES(VALUE1,VALUE2……..VALUEN);
QUERIES TO BE USED
WITH MYSQL
• MYSQLI_CONNECT();
• The mysqli_connect() function opens a
MySQL connection.
• This function returns the connection on
success, or FALSE on failure.
CONT..
• MYSQLI_QUERY($CON,”QUERY”);
• MYSQLI_CLOSE($CON);
• Closes a previously opened database
connection
FETCHING DATA FROM
MYSQL DATABASE
ORDER BY RAND()
FUNCTION IN MYSQL
• MySQL has a ORDER BY RAND()
function that can be used to randomize the
set of values.
• SYNTAX
• SELECT * FROM TABLE_NAME ORDER
BY RAND();
WORDPRESS
WordPress is a free and open source blogging tool and a contentmanagement system based on PHP and MySQL.

WordPress is an OPEN SOURCE project, which means there are
hundreds of people all over the world working on it.

WordPress started as just a blogging system, but has evolved to
be used as full content management system and so much more
through the thousands of plugins and widgets and themes.
WordPress is limited only by your imagination.
Learn Php in Delhi

Php Training Workshop by Vtips

  • 1.
  • 2.
  • 3.
  • 4.
    DEFINITION PHP is aserver side scripting language that is embedded in HTML. It is used to manage dynamic content in your website.
  • 5.
  • 6.
    "Hello World" Scriptin PHP <HTML> <HEAD> <TITLE> First program <TITLE> <BODY> <BODY> </HTML> HELLO WORLD! <?php echo "Hello, World!"; </HEAD> </BODY ?>
  • 7.
    VARIABLES IN PHP Allvariables are declared with leading dollar($) sign. $vary=34; $many=5.34; Variable can, but do not need to be declared before assignment. PHP does a good job of automatically converting types from one to another when necessary. $sum=34; $sum=“hiii”;
  • 8.
    OPERATORS Arithmetic Operators Logical (orRelational) Operators Assignment Operators Conditional (or ternary) Operators
  • 9.
    DATE FUNCTION INPHP • date(format) EXAMPLE:DATE( ); • Print date with time EXAMPLE:DATE( “d-m-y h:m:s” );
  • 10.
    Time zones • Toset the time zone date_default_timezone_set(); • To get the time zone date_default_timezone_get();
  • 11.
    ARRAYS IN PHP •Numeric array An array with a numeric index. Values are stored and accessed in linear fashion • Associative array An array with strings as index. This stores element values in association with key values rather than in a strict linear index order.
  • 12.
    Example (Numeric arrays) •<?php $cars=array("Volvo","BMW","Toyota"); • Echo “I like”.$cars[2]; • ?>
  • 13.
    Example (associative array) • • • • • • • • • • <html> <body> <?php $salaries['mohammad']= "high"; $salaries['qadir'] = "medium"; $salaries['zara'] = "low"; echo "Salary of qadir is ". $salaries['qadir']."<br/>"; ?> </body> </html>
  • 14.
    HEADER,INCLUDE AND REQUIRE • HEADER ITIS USED TO REDIRECT TO ANOTHER PAGE. • INCLUDE IT IS USED TO INCLUDE THE ANOTHER PAGE INTO THE CURRENT PAGE. • REQUIRE SAME AS INCLUDE.
  • 16.
    STEP 1 :-TO ESTABLISH CONNECTION mysql_connect(host,username,password,databasename); <? PHP $LINK=MYSQL_CONNECT(“LOCALHOST”,”ROOT”,””,”myd”); IF($LINK) { ECHO “CONNECTION ESTABLISHED” }
  • 17.
    MYSQL BASIC QUERIES •TO CREATE DATABASE CREATE DATABASE DB_NAME; • TO CREATE TABLE CREATE TABLE TB_NAME(COL_NM1 DATATYPE,COL_NM2 DATATYPE……); • TO LIST THE DATA SELECT * FROM TABLE_NAME;
  • 18.
    • TO INSERTVALUES IN TABLE INSERT INTO TABLE_NAME VALUES(VALUE1,VALUE2……..VALUEN);
  • 19.
    QUERIES TO BEUSED WITH MYSQL • MYSQLI_CONNECT(); • The mysqli_connect() function opens a MySQL connection. • This function returns the connection on success, or FALSE on failure.
  • 20.
    CONT.. • MYSQLI_QUERY($CON,”QUERY”); • MYSQLI_CLOSE($CON); •Closes a previously opened database connection
  • 21.
  • 22.
    ORDER BY RAND() FUNCTIONIN MYSQL • MySQL has a ORDER BY RAND() function that can be used to randomize the set of values. • SYNTAX • SELECT * FROM TABLE_NAME ORDER BY RAND();
  • 23.
    WORDPRESS WordPress is afree and open source blogging tool and a contentmanagement system based on PHP and MySQL. WordPress is an OPEN SOURCE project, which means there are hundreds of people all over the world working on it. WordPress started as just a blogging system, but has evolved to be used as full content management system and so much more through the thousands of plugins and widgets and themes. WordPress is limited only by your imagination.
  • 24.