SlideShare a Scribd company logo
WEB
PROGRAMMING
USING PHP
21BCA2T461-CREDITS: 4
TOTAL HOURS: 60 COURSE TYPE: DSC
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 1
4/30/2024
Learning Objective
 To understand the real-life web development and
trending technologies.
 To gain experience in working with database
connectivity for web application.
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 2
4/30/2024
Outcomes
 Interpret the software’s used and its configuration.
 Define built in functions and arrays in php.
 Illustrate the usage of form handling process in web application.
 Facilitate the connectivity between frontend and backend database.
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 3
4/30/2024
Introduction to Laravel, installation of php, php configuration
Apache web server, features, parsing and embedding php with
html, executing php program, data types, operators, variables,
access specifiers and comment statement.
Unit 1: Introduction
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 4
4/30/2024
What is
● 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 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"
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 5
4/30/2024
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
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 6
4/30/2024
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 7
4/30/2024
Features of PHP
Performance:
PHP script is executed much faster than those scripts
which are written in other languages such as JSP and
ASP.
Open Source:
PHP source code and software are freely available on
the web. You can develop all the versions of PHP
according to your requirement without paying any cost.
cost. All its components are free to download and use.
Familiarity with syntax:
PHP has easily understandable syntax. Programmers
are comfortable coding with it.
Embedded:
PHP code can be easily embedded within HTML tags
and script.
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 8
4/30/2024
Features of PHP
Platform Independent:
PHP is available for WINDOWS, MAC, LINUX & UNIX
operating system. A PHP application developed in
one OS can be easily executed in other OS also.
Database Support:
PHP supports all the leading databases such as
MySQL, SQLite, ODBC, etc.
Error Reporting -
PHP has predefined error reporting constants to
generate an error notice or warning at runtime. E.g.,
E_ERROR, E_WARNING, E_STRICT, E_PARSE.
Loosely Typed Language:
PHP allows us to use a variable without declaring its
datatype. It will be taken automatically at the time
of execution based on the type of data it contains on
its value.
9
Features of PHP
Web servers Support:
PHP is compatible with almost all local servers used
today like Apache, Netscape, Microsoft IIS, etc.
Security:
PHP is a secure language to develop the website. It
consists of multiple layers of security to prevent
threads and malicious attacks.
Control:
Different programming languages require long script
or code, whereas PHP can do the same work in a
few lines of code. It has maximum control over the
websites like you can make changes easily whenever
you want.
A Helpful PHP Community:
It has a large community of developers who
regularly updates documentation, tutorials, online
help, and FAQs. Learning PHP from the communities
is one of the significant benefits.
10
Introduction to LARAVEL
Laravel is a popular open-source PHP web application framework
known for its elegant syntax, developer-friendly tools, and robust
features. It was created by Taylor Otwell and was first released in
2011. Laravel follows the model-view-controller (MVC)
architectural pattern, making it easy for developers to organize
their code and build scalable and maintainable web applications.
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 11
4/30/2024
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP
Some key features and concepts associated with
Laravel
o Eloquent ORM (Object-Relational Mapping)
o Blade Templating Engine
o Artisan Console
o Middleware
o Routing
o Dependency Injection and IoC Container
o Laravel Mix
o Authentication and Authorization
o Database Migrations and Seeding
o Task Scheduling and Queues
12
4/30/2024
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP
Eloquent ORM (Object-Relational Mapping): Laravel includes an ORM (Object-Relational Mapping)
called Eloquent, which simplifies database interactions by allowing developers to work with databases
using an object-oriented syntax. This helps in managing database records using PHP syntax instead of
writing raw SQL queries.
Blade Templating Engine: Blade is the templating engine used in the Laravel PHP framework. It
provides a simple yet powerful way to work with views in Laravel, allowing developers to write clean
and expressive templates for their web applications. Blade templates are designed to be easy to read,
concise, and feature-rich, making them a key component of Laravel's templating system..
Artisan Console: Laravel comes with a powerful command-line tool called Artisan. It provides various
commands for common tasks such as database migrations, seeding, testing, and more. Developers can
also create their own custom Artisan commands.(The Artisan console is a powerful tool that allows
developers to interact with their Laravel application from the command line.)
Middleware: Middleware in Laravel allows you to filter HTTP requests entering your application. This
can be useful for tasks such as authentication, logging, or modifying incoming requests before they
reach the application.
Routing:Routing in Laravel refers to the process of defining how your application responds to specific
HTTP requests. It determines which controller method should handle a particular HTTP request made
to your application. Laravel provides a powerful and expressive routing system that allows developers
to define routes in a clean and organized manner.
13
4/30/2024
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP
Dependency Injection and IoC Container: Dependency Injection (DI) and the Inversion of Control (IoC)
Container are fundamental concepts that contribute to the framework's flexibility, modularity, and
maintainability. This makes it easier to manage class dependencies and facilitates unit testing.
Laravel Mix: Laravel Mix is a tool provided by Laravel for simplifying the process of managing and compiling
assets, such as JavaScript and CSS files, in web applications. It's built on top of Webpack, which is a popular
module bundler for modern JavaScript applications.
Authentication and Authorization: Laravel provides a simple and comprehensive system for user
authentication. Additionally, it includes a robust authorization system that can be easily customized to suit
the needs of your application.
Database Migrations and Seeding: Laravel's migration system allows developers to version-control the
database schema, making it easy to share databases across development teams. Seeders help populate the
database with sample or default data.
Task Scheduling and Queues: Laravel provides a convenient way to schedule tasks using the task scheduler.
Queues allow you to defer the processing of time-consuming tasks, improving the responsiveness of your
application.
14
4/30/2024
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP
Installation of php
To install PHP on your system, you can follow different steps depending on your operating
system. Here are instructions for the most common operating systems:
For Windows:
Using XAMPP:
Download and install XAMPP, which includes PHP, Apache, MySQL, and other components.
Follow the installation wizard to set up XAMPP.
Start the Apache server.
Using WampServer:
Download and install WampServer.
Follow the installation instructions.
Once installed, start WampServer, and it will automatically start the Apache server with PHP.
15
4/30/2024
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP
Verifying Installation:
After installation, you can verify that PHP is installed by opening a terminal or command prompt and typing:
php -v
This command should display the PHP version installed on your system.
To run a PHP script, create a file with a .php extension, for example, hello.php, and add the following content:
<?php
echo "Hello, World!";
?>
Save the file and run it using the following command in the terminal or command prompt:
php hello.php
16
4/30/2024
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 17
4/30/2024
How PHP code is parsed
1. The Web browser requests a document with a .php extension.
2. The Web server sends the request on to the PHP parser.
3. The PHP parser scans the requested file for PHP code.
4. When the PHP parser finds PHP code, it executes that code and places the resulting output (if
any) into the place in the file formerly occupied by the code.
5. This new output file is sent back to the Web server.
6. The Web server sends the output file along to the Web browser.
7. The Web browser displays the output.
18
Because the PHP code is parsed by the server, this
method of code execution is called server-side. When
code is executed by the browser, such as with JavaScript,
it is called client-side.
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 19
4/30/2024
Basic PHP Syntax
1. A PHP script can be placed
anywhere in the document.
1. A PHP script starts with <?php and
ends with ?>
<?php
// PHP code goes here
?>
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 20
4/30/2024
The default file extension for PHP files is
".php".
A PHP file normally contains HTML tags,
and some PHP scripting code.
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 21
4/30/2024
PHP Case Sensitivity
In PHP, keywords (e.g. if, else,
while, echo, etc.), classes,
functions, and user-defined
functions are not case-sensitive.
22
Executing PHP and viewing in browser
● PHP File
● Save in htdocs
● Open browser
● Local Host
● Open the file path
23
Embedding PHP and HTML
<html>
<title>HTML with PHP</title>
<body>
<h1>My Example</h1>
<?php
//your PHP code goes here
?>
<b>Here is some more HTML</b>
<?php
//more PHP code
?>
</body>
</html>
24
PHP Variables
Variables are "containers" for storing information.
In PHP, a variable starts with the $ sign, followed by the name of the variable:
<?php
$txt = "Hello world!";
$x = 5;
$y = 10.5;
?>
25
PHP Variables
A variable can have a short name (like x and y) or a more descriptive name
(age, carname, total_volume).
Rules for PHP variables:
● A variable starts with the $ sign, followed by the name of the variable
● A variable name must start with a letter or the underscore character
● A variable name cannot start with a number
● A variable name can only contain alpha-numeric characters and
underscores (A-z, 0-9, and _ )
● Variable names are case-sensitive ($age and $AGE are two different
variables)
Remember that PHP variable names are case-sensitive!
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 26
4/30/2024
Output Variables
The PHP echo statement is often used to output data to the
screen.
<?php
$txt = "Kristu Jayanti College";
echo "I love $txt!";
?>
27
Output Variables
<?php
$txt = "Kristu Jayanti College";
echo "I love " . $txt . "!";
?>
28
Output Variables
<?php
$x = 5;
$y = 4;
echo $x + $y;
?>
29
PHP Data Types
PHP Data Types
Variables can store data of different types, and different data types can do different things.
PHP supports the following data types:
● String
● Integer
● Float (floating point numbers - also called double)
● Boolean
● Array
● Object
● NULL
30
PHP Data Types
PHP String
● A string is a sequence of characters, like "Hello world!".
● A string can be any text inside quotes. You can use single or double quotes:
<?php
$x = "Hello world!";
$y = 'Hello world!';
echo $x;
echo "<br>";
echo $y;
?>
31
PHP Data Types
PHP Integer
An integer data type is a non-decimal number between -2,147,483,648 and 2,147,483,647.
Rules for integers:
● An integer must have at least one digit
● An integer must not have a decimal point
● An integer can be either positive or negative
● Integers can be specified in: decimal (base 10), hexadecimal (base 16), octal (base 8), or binary (base 2)
notation
32
PHP Data Types
● In the following example $x is an integer. The PHP var_dump() function returns the data type and value:
<?php
$x = 5985;
var_dump($x);
?>
var_dump() provides detailed information about each variable, including its data type and value.
33
PHP Data Types
PHP Float
A float (floating point number) is a number with a decimal point or a number in exponential form.
<?php
$x = 10.365;
var_dump($x);
?>
34
PHP Data Types
PHP Boolean
A Boolean represents two possible states: TRUE or FALSE.
$x = true;
$y = false;
35
PHP Data Types
PHP Array
An array stores multiple values in one single variable.
In the following example $cars is an array.
<?php
$cars = array("Volvo","BMW","Toyota");
var_dump($cars);
?>
36
PHP Data Types
PHP Object
Classes and objects are the two main aspects of object-oriented programming.
A class is a template for objects, and an object is an instance of a class.
When the individual objects are created, they inherit all the properties and behaviors from the
class, but each object will have different values for the properties.
Let's assume we have a class named Car. A Car can have properties like model, color, etc. We
can define variables like $model, $color, and so on, to hold the values of these properties.
When the individual objects (Volvo, BMW, Toyota, etc.) are created, they inherit all the
properties and behaviors from the class, but each object will have different values for the
properties.
37
PHP Data Types
PHP NULL Value
Null is a special data type which can have only one value: NULL.
A variable of data type NULL is a variable that has no value assigned to it.
If a variable is created without a value, it is automatically assigned a value of NULL.
<?php
$x = "Hello world!";
$x = null;
var_dump($x);
38
PHP Comments
Syntax for single-line comments:
<?php
// This is a single-line comment
# This is also a single-line comment
?>
39
PHP Comments
Syntax for multiple-line comments:
<?php
/*
This is a multiple-lines comment block
that spans over multiple
lines
*/
?>
40
Output?
<?php
// You can also use comments to leave out parts of a code line
$x = 5 /* + 15 */ + 5;
echo $x;
?>
41
PHP Operators
PHP Operators
Operators are used to perform operations on variables and values.
PHP divides the operators in the following groups:
● Arithmetic operators
● Assignment operators
● Comparison operators
● Increment/Decrement operators
● Logical operators
● String operators
● Array operators
● Conditional assignment operators
42
PHP Arithmetic Operators
The PHP arithmetic operators are used with numeric values to perform common arithmetical operations, such as
addition, subtraction, multiplication etc.
43
PHP Assignment Operators
The PHP assignment operators are used with numeric values to write a value to a variable.
The basic assignment operator in PHP is "=". It means that the left operand gets set to the value of the
assignment expression on the right.
44
PHP Assignment Operators
<?php
$x = 15;
$x %= 4;
echo $x;
?>
45
PHP Comparison Operators
spaceship operator
46
PHP Comparison Operators
spaceship operator
The spaceship operator or combined comparison operator is denoted by “<=>“. This is a three-way comparison operator and
it can perform greater than, less than and equal comparison between two operands.
This operator has similar behavior like strcmp() . This operator can be used with integers, floats, strings, arrays, objects, etc.
This <=> operator offers combined comparison :
● Return 0 if values on either side are equal
● Return 1 if value on the left is greater
● Return -1 if the value on the right is greater
47
PHP Comparison Operators
The PHP comparison operators are used to compare two values (number or string):
● Example:
● // Comparing Integers
● echo 1 <=> 1; // outputs 0
● echo 3 <=> 4; // outputs -1
● echo 4 <=> 3; // outputs 1
● // String Comparison
● echo "a" <=> "a"; // outputs 0
● echo "m" <=> "y"; // outputs -1
● echo "y" <=> "c"; // outputs 1
48
PHP Comparison Operators
The PHP comparison operators are used to compare two values (number or string):
<?php
$x = 100;
$y = "100";
if ($x == $y)
{
echo
"TRUE";
}
else
<?php
$x = 100;
$y = "100";
if ($x === $y)
{
echo
"TRUE";
}
else 49
PHP Increment / Decrement Operators
The PHP increment operators are used to increment a variable's value.
The PHP decrement operators are used to decrement a variable's value.
50
<?php
$x = 10;
echo ++$x;
?>
<?php
$x = 10;
echo $x++;
?>
51
PHP Logical Operators
The PHP logical operators are used to combine conditional statements.
52
PHP Logical Operators
The PHP logical operators are used to combine conditional statements.
<?php
$x = 100;
$y = 50;
if ($x == 100 and $y == 50) {
echo "Hello world!";
}
?>
53
PHP Logical Operators
The PHP logical operators are used to combine conditional statements.
<?php
$x = 100;
$y = 50;
if ($x == 100 or $y == 80) {
echo "Hello world!";
}
?>
54
PHP Logical Operators
The PHP logical operators are used to combine conditional statements.
<?php
$x = 100;
$y = 50;
if ($x == 100 xor $y == 80) {
echo "Hello world!";
}
?>
55
PHP String Operators
PHP has two operators that are specially designed for strings.
<?php
$txt1 = "Hello";
$txt2 = " world!";
echo $txt1 . $txt2;
?>
<?php
$txt1 = "Hello";
$txt2 = " world!";
$txt1 .= $txt2;
echo $txt1;
?>
56
Access Specifiers in PHP
There are 3 types of Access Specifiers available in PHP, Public, Private and Protected.
• Public - class members with this access modifier will be publicly accessible from anywhere,
anywhere, even from outside the scope of the class.
• Private - class members with this keyword will be accessed within the class itself. It protects
protects members from outside class access with the reference of the class instance.
• Protected - same as private, except by allowing subclasses to access protected superclass
members.
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 57
4/30/2024
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP
EXAMPLE 1: Public
<?php
class demo
{
public $name="Ajeet";
functiondisp()
{
echo $this->name."<br/>";
}
}
class child extends demo
{
function show()
{
echo $this->name;
}
}
$obj= new child;
echo $obj->name."<br/>";
$obj->disp();
$obj->show();
?>
58
4/30/2024
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 59
4/30/2024
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP
EXAMPLE 2: Private
<?php
classJavatpoint
{
private $name="Sonoo";
private function show()
{
echo "This is private method of parent class";
}
}
class child extends Javatpoint
{
function show1()
{
echo $this->name;
}
}
$obj= new child;
$obj->show();
$obj->show1();
?>
60
4/30/2024
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 61
4/30/2024
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP
EXAMPLE 3: Protected
<?php
classJavatpoint
{
protected $x=500;
protected $y=100;
function add()
{
echo $sum=$this->x+$this->y."<br/>";
}
}
class child extends Javatpoint
{
function sub()
{
echo $sub=$this->x-$this->y."<br/>";
}
}
$obj= new child;
$obj->add();
$obj->sub();
?> 62
4/30/2024
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 63
4/30/2024
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP
EXAMPLE 4: Public,Private and Protected
<?php
classJavatpoint
{
public $name="Ajeet";
protected $profile="HR";
private $salary=5000000;
public function show()
{
echo "Welcome : ".$this->name."<br/>";
echo "Profile : ".$this->profile."<br/>";
echo "Salary : ".$this->salary."<br/>";
}
}
classchilds extends Javatpoint
{
public function show1()
{
echo "Welcome : ".$this->name."<br/>";
echo "Profile : ".$this->profile."<br/>";
echo "Salary : ".$this->salary."<br/>";
}
}
$obj= new childs;
$obj->show1();
?>
64
4/30/2024
VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 65
4/30/2024

More Related Content

Similar to introduction to web programming using PHP (20)

Chapter onehsfhjfgjhdjhdhfsGfhghsgasg (2).pptx
Chapter onehsfhjfgjhdjhdhfsGfhghsgasg (2).pptxChapter onehsfhjfgjhdjhdhfsGfhghsgasg (2).pptx
Chapter onehsfhjfgjhdjhdhfsGfhghsgasg (2).pptx
berihun18
 
Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1
Mohd Harris Ahmad Jaal
 
PHP Web Development: Empowering the Digital World
PHP Web Development: Empowering the Digital WorldPHP Web Development: Empowering the Digital World
PHP Web Development: Empowering the Digital World
company
 
Php intro
Php introPhp intro
Php intro
sana mateen
 
lec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoi
lec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoilec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoi
lec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoi
PedakotaPavankumar
 
The evolution of web development with PHP: an overview of key features and ad...
The evolution of web development with PHP: an overview of key features and ad...The evolution of web development with PHP: an overview of key features and ad...
The evolution of web development with PHP: an overview of key features and ad...
Hauper Technologies
 
PHP Training In Chandigarh.docx
PHP Training In Chandigarh.docxPHP Training In Chandigarh.docx
PHP Training In Chandigarh.docx
Excellence Academy
 
PHP .pdf
PHP .pdfPHP .pdf
PHP .pdf
execellencetechnolog
 
PHP Web Development.pdf
PHP Web Development.pdfPHP Web Development.pdf
PHP Web Development.pdf
Fariha Tasnim
 
Introduction to PHP.pptx
Introduction to PHP.pptxIntroduction to PHP.pptx
Introduction to PHP.pptx
MarianJRuben
 
PHP TRAINING
PHP TRAININGPHP TRAINING
PHP TRAINING
gurjinderbains
 
t1837
t1837t1837
t1837
tutorialsruby
 
t1837
t1837t1837
t1837
tutorialsruby
 
PHP MySQL Workshop - facehook
PHP MySQL Workshop - facehookPHP MySQL Workshop - facehook
PHP MySQL Workshop - facehook
Shashank Skills Academy
 
PHP Web Development
PHP Web DevelopmentPHP Web Development
PHP Web Development
Sanjida Afrin
 
INTRODUCTION TO PHP.ppt
INTRODUCTION TO PHP.pptINTRODUCTION TO PHP.ppt
INTRODUCTION TO PHP.ppt
WASIYANILOFARDPSNACH
 
How PHP works
How PHP works How PHP works
How PHP works
Atlogys Technical Consulting
 
Why do businesses choose PHP as their development language?
Why do businesses choose PHP as their development language?Why do businesses choose PHP as their development language?
Why do businesses choose PHP as their development language?
AResourcePool
 
PHP Fundamentals: A Comprehensive Introduction
PHP Fundamentals: A Comprehensive IntroductionPHP Fundamentals: A Comprehensive Introduction
PHP Fundamentals: A Comprehensive Introduction
Nilesh Valva
 
PHP LICTURES ..........
PHP LICTURES ..........PHP LICTURES ..........
PHP LICTURES ..........
Rashid Ahmad
 
Chapter onehsfhjfgjhdjhdhfsGfhghsgasg (2).pptx
Chapter onehsfhjfgjhdjhdhfsGfhghsgasg (2).pptxChapter onehsfhjfgjhdjhdhfsGfhghsgasg (2).pptx
Chapter onehsfhjfgjhdjhdhfsGfhghsgasg (2).pptx
berihun18
 
Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1
Mohd Harris Ahmad Jaal
 
PHP Web Development: Empowering the Digital World
PHP Web Development: Empowering the Digital WorldPHP Web Development: Empowering the Digital World
PHP Web Development: Empowering the Digital World
company
 
lec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoi
lec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoilec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoi
lec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoi
PedakotaPavankumar
 
The evolution of web development with PHP: an overview of key features and ad...
The evolution of web development with PHP: an overview of key features and ad...The evolution of web development with PHP: an overview of key features and ad...
The evolution of web development with PHP: an overview of key features and ad...
Hauper Technologies
 
PHP Training In Chandigarh.docx
PHP Training In Chandigarh.docxPHP Training In Chandigarh.docx
PHP Training In Chandigarh.docx
Excellence Academy
 
PHP Web Development.pdf
PHP Web Development.pdfPHP Web Development.pdf
PHP Web Development.pdf
Fariha Tasnim
 
Introduction to PHP.pptx
Introduction to PHP.pptxIntroduction to PHP.pptx
Introduction to PHP.pptx
MarianJRuben
 
Why do businesses choose PHP as their development language?
Why do businesses choose PHP as their development language?Why do businesses choose PHP as their development language?
Why do businesses choose PHP as their development language?
AResourcePool
 
PHP Fundamentals: A Comprehensive Introduction
PHP Fundamentals: A Comprehensive IntroductionPHP Fundamentals: A Comprehensive Introduction
PHP Fundamentals: A Comprehensive Introduction
Nilesh Valva
 
PHP LICTURES ..........
PHP LICTURES ..........PHP LICTURES ..........
PHP LICTURES ..........
Rashid Ahmad
 

More from vishnupriyapm4 (20)

UNIT_1_-_Introduction_to_Cyber_Security_Updated.pptx
UNIT_1_-_Introduction_to_Cyber_Security_Updated.pptxUNIT_1_-_Introduction_to_Cyber_Security_Updated.pptx
UNIT_1_-_Introduction_to_Cyber_Security_Updated.pptx
vishnupriyapm4
 
PCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptxPCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptx
vishnupriyapm4
 
pccf unit 1 _VP.pptx
pccf unit 1 _VP.pptxpccf unit 1 _VP.pptx
pccf unit 1 _VP.pptx
vishnupriyapm4
 
Introduction to DBMS_VP.pptx
Introduction to DBMS_VP.pptxIntroduction to DBMS_VP.pptx
Introduction to DBMS_VP.pptx
vishnupriyapm4
 
Entity_DBMS.pptx
Entity_DBMS.pptxEntity_DBMS.pptx
Entity_DBMS.pptx
vishnupriyapm4
 
Unit 2function in python.pptx
Unit 2function in python.pptxUnit 2function in python.pptx
Unit 2function in python.pptx
vishnupriyapm4
 
Unit 3_Numpy_VP.pptx
Unit 3_Numpy_VP.pptxUnit 3_Numpy_VP.pptx
Unit 3_Numpy_VP.pptx
vishnupriyapm4
 
Unit 3_Numpy_VP.pptx
Unit 3_Numpy_VP.pptxUnit 3_Numpy_VP.pptx
Unit 3_Numpy_VP.pptx
vishnupriyapm4
 
Unit 2function in python.pptx
Unit 2function in python.pptxUnit 2function in python.pptx
Unit 2function in python.pptx
vishnupriyapm4
 
OPS Ecosystem and Engineering.pptx
OPS Ecosystem and Engineering.pptxOPS Ecosystem and Engineering.pptx
OPS Ecosystem and Engineering.pptx
vishnupriyapm4
 
Open Source VP.pptx
Open Source VP.pptxOpen Source VP.pptx
Open Source VP.pptx
vishnupriyapm4
 
Project Planning and Management.pptx
Project Planning and Management.pptxProject Planning and Management.pptx
Project Planning and Management.pptx
vishnupriyapm4
 
Software_Process_Model for class.ppt
Software_Process_Model for class.pptSoftware_Process_Model for class.ppt
Software_Process_Model for class.ppt
vishnupriyapm4
 
2.java intro.pptx
2.java intro.pptx2.java intro.pptx
2.java intro.pptx
vishnupriyapm4
 
features of JAVA.pptx
features of JAVA.pptxfeatures of JAVA.pptx
features of JAVA.pptx
vishnupriyapm4
 
php user defined functions
php user defined functionsphp user defined functions
php user defined functions
vishnupriyapm4
 
Session and cookies in php
Session and cookies in phpSession and cookies in php
Session and cookies in php
vishnupriyapm4
 
constant in C
constant in Cconstant in C
constant in C
vishnupriyapm4
 
File Handling in C
File Handling in CFile Handling in C
File Handling in C
vishnupriyapm4
 
Break and continue in C
Break and continue in C Break and continue in C
Break and continue in C
vishnupriyapm4
 
UNIT_1_-_Introduction_to_Cyber_Security_Updated.pptx
UNIT_1_-_Introduction_to_Cyber_Security_Updated.pptxUNIT_1_-_Introduction_to_Cyber_Security_Updated.pptx
UNIT_1_-_Introduction_to_Cyber_Security_Updated.pptx
vishnupriyapm4
 
PCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptxPCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptx
vishnupriyapm4
 
Introduction to DBMS_VP.pptx
Introduction to DBMS_VP.pptxIntroduction to DBMS_VP.pptx
Introduction to DBMS_VP.pptx
vishnupriyapm4
 
Unit 2function in python.pptx
Unit 2function in python.pptxUnit 2function in python.pptx
Unit 2function in python.pptx
vishnupriyapm4
 
Unit 2function in python.pptx
Unit 2function in python.pptxUnit 2function in python.pptx
Unit 2function in python.pptx
vishnupriyapm4
 
OPS Ecosystem and Engineering.pptx
OPS Ecosystem and Engineering.pptxOPS Ecosystem and Engineering.pptx
OPS Ecosystem and Engineering.pptx
vishnupriyapm4
 
Project Planning and Management.pptx
Project Planning and Management.pptxProject Planning and Management.pptx
Project Planning and Management.pptx
vishnupriyapm4
 
Software_Process_Model for class.ppt
Software_Process_Model for class.pptSoftware_Process_Model for class.ppt
Software_Process_Model for class.ppt
vishnupriyapm4
 
php user defined functions
php user defined functionsphp user defined functions
php user defined functions
vishnupriyapm4
 
Session and cookies in php
Session and cookies in phpSession and cookies in php
Session and cookies in php
vishnupriyapm4
 
Break and continue in C
Break and continue in C Break and continue in C
Break and continue in C
vishnupriyapm4
 
Ad

Recently uploaded (20)

Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18
Celine George
 
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
National Information Standards Organization (NISO)
 
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
Quiz Club of PSG College of Arts & Science
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 SlidesHow to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
How to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 SalesHow to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 Sales
Celine George
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
Strengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptxStrengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptx
SteffMusniQuiballo
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
EduSkills OECD
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18
Celine George
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 SlidesHow to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
How to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 SalesHow to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 Sales
Celine George
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
Strengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptxStrengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptx
SteffMusniQuiballo
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
EduSkills OECD
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
Ad

introduction to web programming using PHP

  • 1. WEB PROGRAMMING USING PHP 21BCA2T461-CREDITS: 4 TOTAL HOURS: 60 COURSE TYPE: DSC VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 1 4/30/2024
  • 2. Learning Objective  To understand the real-life web development and trending technologies.  To gain experience in working with database connectivity for web application. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 2 4/30/2024
  • 3. Outcomes  Interpret the software’s used and its configuration.  Define built in functions and arrays in php.  Illustrate the usage of form handling process in web application.  Facilitate the connectivity between frontend and backend database. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 3 4/30/2024
  • 4. Introduction to Laravel, installation of php, php configuration Apache web server, features, parsing and embedding php with html, executing php program, data types, operators, variables, access specifiers and comment statement. Unit 1: Introduction VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 4 4/30/2024
  • 5. What is ● 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 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" VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 5 4/30/2024
  • 6. 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 VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 6 4/30/2024
  • 7. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 7 4/30/2024
  • 8. Features of PHP Performance: PHP script is executed much faster than those scripts which are written in other languages such as JSP and ASP. Open Source: PHP source code and software are freely available on the web. You can develop all the versions of PHP according to your requirement without paying any cost. cost. All its components are free to download and use. Familiarity with syntax: PHP has easily understandable syntax. Programmers are comfortable coding with it. Embedded: PHP code can be easily embedded within HTML tags and script. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 8 4/30/2024
  • 9. Features of PHP Platform Independent: PHP is available for WINDOWS, MAC, LINUX & UNIX operating system. A PHP application developed in one OS can be easily executed in other OS also. Database Support: PHP supports all the leading databases such as MySQL, SQLite, ODBC, etc. Error Reporting - PHP has predefined error reporting constants to generate an error notice or warning at runtime. E.g., E_ERROR, E_WARNING, E_STRICT, E_PARSE. Loosely Typed Language: PHP allows us to use a variable without declaring its datatype. It will be taken automatically at the time of execution based on the type of data it contains on its value. 9
  • 10. Features of PHP Web servers Support: PHP is compatible with almost all local servers used today like Apache, Netscape, Microsoft IIS, etc. Security: PHP is a secure language to develop the website. It consists of multiple layers of security to prevent threads and malicious attacks. Control: Different programming languages require long script or code, whereas PHP can do the same work in a few lines of code. It has maximum control over the websites like you can make changes easily whenever you want. A Helpful PHP Community: It has a large community of developers who regularly updates documentation, tutorials, online help, and FAQs. Learning PHP from the communities is one of the significant benefits. 10
  • 11. Introduction to LARAVEL Laravel is a popular open-source PHP web application framework known for its elegant syntax, developer-friendly tools, and robust features. It was created by Taylor Otwell and was first released in 2011. Laravel follows the model-view-controller (MVC) architectural pattern, making it easy for developers to organize their code and build scalable and maintainable web applications. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 11 4/30/2024
  • 12. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP Some key features and concepts associated with Laravel o Eloquent ORM (Object-Relational Mapping) o Blade Templating Engine o Artisan Console o Middleware o Routing o Dependency Injection and IoC Container o Laravel Mix o Authentication and Authorization o Database Migrations and Seeding o Task Scheduling and Queues 12 4/30/2024
  • 13. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP Eloquent ORM (Object-Relational Mapping): Laravel includes an ORM (Object-Relational Mapping) called Eloquent, which simplifies database interactions by allowing developers to work with databases using an object-oriented syntax. This helps in managing database records using PHP syntax instead of writing raw SQL queries. Blade Templating Engine: Blade is the templating engine used in the Laravel PHP framework. It provides a simple yet powerful way to work with views in Laravel, allowing developers to write clean and expressive templates for their web applications. Blade templates are designed to be easy to read, concise, and feature-rich, making them a key component of Laravel's templating system.. Artisan Console: Laravel comes with a powerful command-line tool called Artisan. It provides various commands for common tasks such as database migrations, seeding, testing, and more. Developers can also create their own custom Artisan commands.(The Artisan console is a powerful tool that allows developers to interact with their Laravel application from the command line.) Middleware: Middleware in Laravel allows you to filter HTTP requests entering your application. This can be useful for tasks such as authentication, logging, or modifying incoming requests before they reach the application. Routing:Routing in Laravel refers to the process of defining how your application responds to specific HTTP requests. It determines which controller method should handle a particular HTTP request made to your application. Laravel provides a powerful and expressive routing system that allows developers to define routes in a clean and organized manner. 13 4/30/2024
  • 14. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP Dependency Injection and IoC Container: Dependency Injection (DI) and the Inversion of Control (IoC) Container are fundamental concepts that contribute to the framework's flexibility, modularity, and maintainability. This makes it easier to manage class dependencies and facilitates unit testing. Laravel Mix: Laravel Mix is a tool provided by Laravel for simplifying the process of managing and compiling assets, such as JavaScript and CSS files, in web applications. It's built on top of Webpack, which is a popular module bundler for modern JavaScript applications. Authentication and Authorization: Laravel provides a simple and comprehensive system for user authentication. Additionally, it includes a robust authorization system that can be easily customized to suit the needs of your application. Database Migrations and Seeding: Laravel's migration system allows developers to version-control the database schema, making it easy to share databases across development teams. Seeders help populate the database with sample or default data. Task Scheduling and Queues: Laravel provides a convenient way to schedule tasks using the task scheduler. Queues allow you to defer the processing of time-consuming tasks, improving the responsiveness of your application. 14 4/30/2024
  • 15. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP Installation of php To install PHP on your system, you can follow different steps depending on your operating system. Here are instructions for the most common operating systems: For Windows: Using XAMPP: Download and install XAMPP, which includes PHP, Apache, MySQL, and other components. Follow the installation wizard to set up XAMPP. Start the Apache server. Using WampServer: Download and install WampServer. Follow the installation instructions. Once installed, start WampServer, and it will automatically start the Apache server with PHP. 15 4/30/2024
  • 16. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP Verifying Installation: After installation, you can verify that PHP is installed by opening a terminal or command prompt and typing: php -v This command should display the PHP version installed on your system. To run a PHP script, create a file with a .php extension, for example, hello.php, and add the following content: <?php echo "Hello, World!"; ?> Save the file and run it using the following command in the terminal or command prompt: php hello.php 16 4/30/2024
  • 17. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 17 4/30/2024
  • 18. How PHP code is parsed 1. The Web browser requests a document with a .php extension. 2. The Web server sends the request on to the PHP parser. 3. The PHP parser scans the requested file for PHP code. 4. When the PHP parser finds PHP code, it executes that code and places the resulting output (if any) into the place in the file formerly occupied by the code. 5. This new output file is sent back to the Web server. 6. The Web server sends the output file along to the Web browser. 7. The Web browser displays the output. 18
  • 19. Because the PHP code is parsed by the server, this method of code execution is called server-side. When code is executed by the browser, such as with JavaScript, it is called client-side. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 19 4/30/2024
  • 20. Basic PHP Syntax 1. A PHP script can be placed anywhere in the document. 1. A PHP script starts with <?php and ends with ?> <?php // PHP code goes here ?> VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 20 4/30/2024
  • 21. The default file extension for PHP files is ".php". A PHP file normally contains HTML tags, and some PHP scripting code. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 21 4/30/2024
  • 22. PHP Case Sensitivity In PHP, keywords (e.g. if, else, while, echo, etc.), classes, functions, and user-defined functions are not case-sensitive. 22
  • 23. Executing PHP and viewing in browser ● PHP File ● Save in htdocs ● Open browser ● Local Host ● Open the file path 23
  • 24. Embedding PHP and HTML <html> <title>HTML with PHP</title> <body> <h1>My Example</h1> <?php //your PHP code goes here ?> <b>Here is some more HTML</b> <?php //more PHP code ?> </body> </html> 24
  • 25. PHP Variables Variables are "containers" for storing information. In PHP, a variable starts with the $ sign, followed by the name of the variable: <?php $txt = "Hello world!"; $x = 5; $y = 10.5; ?> 25
  • 26. PHP Variables A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). Rules for PHP variables: ● A variable starts with the $ sign, followed by the name of the variable ● A variable name must start with a letter or the underscore character ● A variable name cannot start with a number ● A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) ● Variable names are case-sensitive ($age and $AGE are two different variables) Remember that PHP variable names are case-sensitive! VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 26 4/30/2024
  • 27. Output Variables The PHP echo statement is often used to output data to the screen. <?php $txt = "Kristu Jayanti College"; echo "I love $txt!"; ?> 27
  • 28. Output Variables <?php $txt = "Kristu Jayanti College"; echo "I love " . $txt . "!"; ?> 28
  • 29. Output Variables <?php $x = 5; $y = 4; echo $x + $y; ?> 29
  • 30. PHP Data Types PHP Data Types Variables can store data of different types, and different data types can do different things. PHP supports the following data types: ● String ● Integer ● Float (floating point numbers - also called double) ● Boolean ● Array ● Object ● NULL 30
  • 31. PHP Data Types PHP String ● A string is a sequence of characters, like "Hello world!". ● A string can be any text inside quotes. You can use single or double quotes: <?php $x = "Hello world!"; $y = 'Hello world!'; echo $x; echo "<br>"; echo $y; ?> 31
  • 32. PHP Data Types PHP Integer An integer data type is a non-decimal number between -2,147,483,648 and 2,147,483,647. Rules for integers: ● An integer must have at least one digit ● An integer must not have a decimal point ● An integer can be either positive or negative ● Integers can be specified in: decimal (base 10), hexadecimal (base 16), octal (base 8), or binary (base 2) notation 32
  • 33. PHP Data Types ● In the following example $x is an integer. The PHP var_dump() function returns the data type and value: <?php $x = 5985; var_dump($x); ?> var_dump() provides detailed information about each variable, including its data type and value. 33
  • 34. PHP Data Types PHP Float A float (floating point number) is a number with a decimal point or a number in exponential form. <?php $x = 10.365; var_dump($x); ?> 34
  • 35. PHP Data Types PHP Boolean A Boolean represents two possible states: TRUE or FALSE. $x = true; $y = false; 35
  • 36. PHP Data Types PHP Array An array stores multiple values in one single variable. In the following example $cars is an array. <?php $cars = array("Volvo","BMW","Toyota"); var_dump($cars); ?> 36
  • 37. PHP Data Types PHP Object Classes and objects are the two main aspects of object-oriented programming. A class is a template for objects, and an object is an instance of a class. When the individual objects are created, they inherit all the properties and behaviors from the class, but each object will have different values for the properties. Let's assume we have a class named Car. A Car can have properties like model, color, etc. We can define variables like $model, $color, and so on, to hold the values of these properties. When the individual objects (Volvo, BMW, Toyota, etc.) are created, they inherit all the properties and behaviors from the class, but each object will have different values for the properties. 37
  • 38. PHP Data Types PHP NULL Value Null is a special data type which can have only one value: NULL. A variable of data type NULL is a variable that has no value assigned to it. If a variable is created without a value, it is automatically assigned a value of NULL. <?php $x = "Hello world!"; $x = null; var_dump($x); 38
  • 39. PHP Comments Syntax for single-line comments: <?php // This is a single-line comment # This is also a single-line comment ?> 39
  • 40. PHP Comments Syntax for multiple-line comments: <?php /* This is a multiple-lines comment block that spans over multiple lines */ ?> 40
  • 41. Output? <?php // You can also use comments to leave out parts of a code line $x = 5 /* + 15 */ + 5; echo $x; ?> 41
  • 42. PHP Operators PHP Operators Operators are used to perform operations on variables and values. PHP divides the operators in the following groups: ● Arithmetic operators ● Assignment operators ● Comparison operators ● Increment/Decrement operators ● Logical operators ● String operators ● Array operators ● Conditional assignment operators 42
  • 43. PHP Arithmetic Operators The PHP arithmetic operators are used with numeric values to perform common arithmetical operations, such as addition, subtraction, multiplication etc. 43
  • 44. PHP Assignment Operators The PHP assignment operators are used with numeric values to write a value to a variable. The basic assignment operator in PHP is "=". It means that the left operand gets set to the value of the assignment expression on the right. 44
  • 45. PHP Assignment Operators <?php $x = 15; $x %= 4; echo $x; ?> 45
  • 47. PHP Comparison Operators spaceship operator The spaceship operator or combined comparison operator is denoted by “<=>“. This is a three-way comparison operator and it can perform greater than, less than and equal comparison between two operands. This operator has similar behavior like strcmp() . This operator can be used with integers, floats, strings, arrays, objects, etc. This <=> operator offers combined comparison : ● Return 0 if values on either side are equal ● Return 1 if value on the left is greater ● Return -1 if the value on the right is greater 47
  • 48. PHP Comparison Operators The PHP comparison operators are used to compare two values (number or string): ● Example: ● // Comparing Integers ● echo 1 <=> 1; // outputs 0 ● echo 3 <=> 4; // outputs -1 ● echo 4 <=> 3; // outputs 1 ● // String Comparison ● echo "a" <=> "a"; // outputs 0 ● echo "m" <=> "y"; // outputs -1 ● echo "y" <=> "c"; // outputs 1 48
  • 49. PHP Comparison Operators The PHP comparison operators are used to compare two values (number or string): <?php $x = 100; $y = "100"; if ($x == $y) { echo "TRUE"; } else <?php $x = 100; $y = "100"; if ($x === $y) { echo "TRUE"; } else 49
  • 50. PHP Increment / Decrement Operators The PHP increment operators are used to increment a variable's value. The PHP decrement operators are used to decrement a variable's value. 50
  • 51. <?php $x = 10; echo ++$x; ?> <?php $x = 10; echo $x++; ?> 51
  • 52. PHP Logical Operators The PHP logical operators are used to combine conditional statements. 52
  • 53. PHP Logical Operators The PHP logical operators are used to combine conditional statements. <?php $x = 100; $y = 50; if ($x == 100 and $y == 50) { echo "Hello world!"; } ?> 53
  • 54. PHP Logical Operators The PHP logical operators are used to combine conditional statements. <?php $x = 100; $y = 50; if ($x == 100 or $y == 80) { echo "Hello world!"; } ?> 54
  • 55. PHP Logical Operators The PHP logical operators are used to combine conditional statements. <?php $x = 100; $y = 50; if ($x == 100 xor $y == 80) { echo "Hello world!"; } ?> 55
  • 56. PHP String Operators PHP has two operators that are specially designed for strings. <?php $txt1 = "Hello"; $txt2 = " world!"; echo $txt1 . $txt2; ?> <?php $txt1 = "Hello"; $txt2 = " world!"; $txt1 .= $txt2; echo $txt1; ?> 56
  • 57. Access Specifiers in PHP There are 3 types of Access Specifiers available in PHP, Public, Private and Protected. • Public - class members with this access modifier will be publicly accessible from anywhere, anywhere, even from outside the scope of the class. • Private - class members with this keyword will be accessed within the class itself. It protects protects members from outside class access with the reference of the class instance. • Protected - same as private, except by allowing subclasses to access protected superclass members. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 57 4/30/2024
  • 58. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP EXAMPLE 1: Public <?php class demo { public $name="Ajeet"; functiondisp() { echo $this->name."<br/>"; } } class child extends demo { function show() { echo $this->name; } } $obj= new child; echo $obj->name."<br/>"; $obj->disp(); $obj->show(); ?> 58 4/30/2024
  • 59. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 59 4/30/2024
  • 60. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP EXAMPLE 2: Private <?php classJavatpoint { private $name="Sonoo"; private function show() { echo "This is private method of parent class"; } } class child extends Javatpoint { function show1() { echo $this->name; } } $obj= new child; $obj->show(); $obj->show1(); ?> 60 4/30/2024
  • 61. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 61 4/30/2024
  • 62. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP EXAMPLE 3: Protected <?php classJavatpoint { protected $x=500; protected $y=100; function add() { echo $sum=$this->x+$this->y."<br/>"; } } class child extends Javatpoint { function sub() { echo $sub=$this->x-$this->y."<br/>"; } } $obj= new child; $obj->add(); $obj->sub(); ?> 62 4/30/2024
  • 63. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 63 4/30/2024
  • 64. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP EXAMPLE 4: Public,Private and Protected <?php classJavatpoint { public $name="Ajeet"; protected $profile="HR"; private $salary=5000000; public function show() { echo "Welcome : ".$this->name."<br/>"; echo "Profile : ".$this->profile."<br/>"; echo "Salary : ".$this->salary."<br/>"; } } classchilds extends Javatpoint { public function show1() { echo "Welcome : ".$this->name."<br/>"; echo "Profile : ".$this->profile."<br/>"; echo "Salary : ".$this->salary."<br/>"; } } $obj= new childs; $obj->show1(); ?> 64 4/30/2024
  • 65. VISHNU PRIYA P M | WEB PROGRAMMING USING PHP 65 4/30/2024

Editor's Notes

  • #14: Laravel's routing system is expressive and easy to use. Developers can define routes in the routes/web.php file for web applications and routes/api.php for API routes. This makes it simple to handle HTTP requests and define the corresponding actions in controllers.
  • #26: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #27: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #28: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #29: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #30: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #31: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #32: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #33: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #34: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #35: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #36: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #37: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #38: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #39: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #40: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #41: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #42: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #43: AASCI LCA
  • #44: Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.
  • #54: True if both $x and $y are true
  • #55: True if either $x or $y is true
  • #56: True if either $x or $y is true, but not both