You are on page 1of 9

BREIF INTRODUCTION TO PHP

What is PHP?

• Its full form is Hypertext Preprocessor.


• Its a open source scripting language.
• PHP scripts are executed on the SERVER.
• Latest version is PHP 8.2 as of November 2022.
• echo works as print.
Syntax of PHP
Syntax:
<? php
//code
?>

Egs:
<?php
$x = 100;
echo “You are useless”;
echo $x;
?>

Output:
You are useless
100
Functions of PHP

• Its does everything that can be done by text, html, js and css files with other various
tasks

• It connects web server with database


• PHP can encrypt data by using algorithms and functions such as crypt(),
password_hash(), md5() etc.

• It can manipulate data on DB.


• It can manipulate files on server.
PHP Connection
PHP Variables And Operations
• PHP variables start with $
Egs:
$x = 10;
$txt = “Once again you are useless”

• PHP operators are =, -, *, /, %,** , =, == etc


Egs:
$y =20;
$z=$x+$y
echo $z;
echo $txt;

Output:
30
Once again you are useless.
PHP Superglobal Variables
There are 9 important super global variables are present which can be accessed regardless of the scope. They are as follows
• $GLOBALS
• $_SERVER
• $_REQUEST
• $_POST
• $_GET
• $_FILES
• $_ENV
• $_COOKIE
• $_SESSION
MySQLi Connection using PHP

Syntax:
$variable_name = mysqli_connect(host, username, password, dbname);

Egs:
$conn - mysqli_connect(“localhost”, “root”, “nopassword”, “resume”);
Questions:

• WAP to print your CGPA


• WAP to print your ______ name
• WAP to execute all taught operations on two variables in a single program.
• Write a 100 word brief conclusion regarding PHP taught in this session.

You might also like