SlideShare a Scribd company logo
PHP Basics

PHP stands for Hypertext Preprocessor and is a server-side language.

This means that the script is run on your web server, not on the user's browser,
so you do not need to worry about compatibility issues.

PHP is relatively new (compared to languages such as Perl (CGI) and Java)
but is quickly becomming one of the most popular scripting languages on the
internet.
WHAT IS PHP?
PHP.INI

The php.ini file is a special file for suPHP (pronounced sue-p-h-p).

The php.ini file is where you declare changes to your PHP settings. You can
edit the existing php.ini, or create a new text file in any subdirectory and name it
php.ini.

Some common changes that you must make when moving from non-secure
php environment to suPHP :
For example, if your site had these settings in a .htaccess file:
php_flag upload_max_filesize 10M
php_value post_max_size 10M
php_value max_execution_time 30
PHP SYNTAX

A PHP scripting block always starts with <?php and ends with ?>. A PHP
scripting block can be placed anywhere in the document.

On servers with shorthand support enabled you can start a scripting block with
<? and end with ?>.

For maximum compatibility, we use the standard form (<?php) rather than the
shorthand form.
PHP VARIABLES

A variable is used to store information, like text strings, numbers or arrays.

When a variable is declared, it can be used over and over again in your script.

All variables in PHP start with a $ sign symbol.

The declaration of php variables is :
$var_name = value;
PHP STRINGS

String variables are used for values that contains characters.

After we create a string we can manipulate it. A string can be used directly in a
function or it can be stored in a variable.

The declaration of a string looks like this :
$my_string = “ABSASDFSDF”;
PHP OPERATORS

In all programming languages, operators are used to manipulate or perform
operations on variables and values.

There are many operators used in PHP, so we have separated them into the
following categories to make it easier to learn them all.
!) Assignment Operators
2) Arithmetic Operators
3) Comparison Operators
4) String Operators
5) Combination Arithmetic & Assignment Operators
ASSIGNMENT OPERATOR

Assignment operators are used to set a variable equal to a value or set a
variable to another variable's value. Such an assignment of value is done with
the "=", or equal character. Example:
$my_var = 4;
$another_var = $my_var;

Now both $my_var and $another_var contain the value 4. Assignments can
also be used in conjunction with arithmetic operators.
ARITHMETIC OPERATOR

The arithmetic operators in php are as follows :
OPERATOR MEANING
+ Addition
- Subtraction
* Muktiplication
/ Division
% Modulus (Division remainder)
++ Increment
-- Decrement
COMPARISON OPERATOR

Comparisons are used to check the relationship between variables and/or
values. If you would like to see a simple example of a comparison operator in
action, check out our If Statement Lesson. Comparison operators are used
inside conditional statements and evaluate to either true or false. Here are the
most important comparison operators of PHP.

The comparison operators in php are :
== means Equals to
!= means Not equal to
< means Less than
> means Greater than
<= means Less than or Equal to
>= means Greater than or equal to
STRING OPERATORS

The operator “.” is the string operator used in PHP.

The string operator is used to concatenate two strings.
COMBINATION ARITHMETIC AND
ASSIGNMENT OPERATOR

It is a combination of assignment and arithmetic operators.

The combination of arithmetic and assignment operators include ;
+= means Plus eqals
-= means Minus equals
*= means Multiply equals
/= means Divide equals
%= means Modulo equals
.= means Concatenate equals
PHP ECHO

The echo() function outputs one or more strings.

It can output all types of data and multiple outputs can be made with only one
echo () command.

For example
<?php
echo “HI”;
?>
Prints the string “HI”.
PHP GET

The GET method sends the encoded user information appended to the page
request. The page and the encoded information are separated by the ?
Character.

The data sent by GET method can be accessed using QUERY_STRING
environment variable.

The PHP provides $_GET associative array to access all the sent information
using GET method.
PHP POST

The POST method transfers information via HTTP headers. The information is
encoded as described in case of GET method and put into a header called
QUERY_STRING.

The POST method does not have any restriction on data size to be sent.

The data sent by POST method goes through HTTP header so security
depends on HTTP protocol. By using Secure HTTP you can make sure that your
information is secure.

The PHP provides $_POST associative array to access all the sent information
using GET method.
PHP FILES

Manipulating files is a basic necessity for serious programmers and PHP gives
you a great deal of tools for creating, uploading, and editing files.

PHP files deals with read, write, append, truncate, and uploading files.
CREATE FILE

In PHP, a file is created using a command that is also used to open files.

In PHP the fopen function is used to open files. However, it can also create a
file if it does not find the file specified in the function call. So if you use fopen on
a file that does not exist, it will create it, given that you open the file for writing or
appending (more on this later).

The fopen function needs two important pieces of information to operate
correctly. First, we must supply it with the name of the file that we want it to
open. Secondly, we must tell the function what we plan on doing with that file
(i.e. read from the file, write information, etc).

The code for Creating a file is as follows :
$ourFileName = "testFile.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
OPEN FILE

The fopen function is used to open a file.

There are different modes to open a file. They are :
(i) Read 'r' : -
Open a file for read only use. The file pointer begins at the front of the
file.
(ii) Write 'w' :-
Open a file for write only use. In addition, the data in the file is erased
and you will begin writing data at the beginning of the file. This is also
called truncating a file, which we will talk about more in a later lesson. The
file pointer begins at the start of the file.
(iii) Append 'a' :-
Opens and writes to the end of the file or creates a new file if it doesn't
exist
CLOSE FILE

The fclose function is used to close a file in php.

The genral structure for closing a file is :
$ourFileName = "testFile.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
PHP SESSIONS

In PHP, a "session" is the time that a user spends on a web site.

A PHP Session allows certain data to be preserved across an access span, by
assigning a unique ID called "Session ID", to each visitor to the site.

This Session ID can be stored as a cookie at the client end, or passed through
a URL.

To start a new session and to destroy a session, The following code must be
used :
<?php
session_start();
//YOUR CODE HERE
session_destroy();
?>
PHP COOKIES

Cookies have been around for quite some time on the internet. They were
invented to allow webmaster's to store information about the user and their visit
on the user's computer.

When you create a cookie, using the function setcookie, you must specify three
arguments. These arguments are setcookie(name, value, expiration):
1. name:
The name of your cookie. You will use this name to later retrieve
your cookie, so don't forget it!
2. value:
The value that is stored in your cookie. Common values are
username(string) and last visit(date).
3. expiration:
The date when the cookie will expire and be deleted. If you do not set
this expiration date, then it will be treated as a session cookie and be
removed when the browser is restarted.
PHP COOKIES

The following sample code is used to retrieve a cookie :
<?php
if(isset($_COOKIE['lastVisit']))
$visit = $_COOKIE['lastVisit'];
else
echo "You've got some stale cookies!";
echo "Your last visit was - ". $visit;
?>
THANK YOU

More Related Content

What's hot

Php
PhpPhp
Php advance
Php advancePhp advance
Php advance
Rattanjeet Singh
 
php
phpphp
PHP NOTES FOR BEGGINERS
PHP NOTES FOR BEGGINERSPHP NOTES FOR BEGGINERS
PHP NOTES FOR BEGGINERS
Aminiel Michael
 
PHP Tutorials
PHP TutorialsPHP Tutorials
PHP Tutorials
Yuriy Krapivko
 
Php1
Php1Php1
Php1
Reka
 
What Is Php
What Is PhpWhat Is Php
What Is Php
AVC
 
Php introduction
Php introductionPhp introduction
Php introduction
krishnapriya Tadepalli
 
Web Development Course: PHP lecture 3
Web Development Course: PHP lecture 3Web Development Course: PHP lecture 3
Web Development Course: PHP lecture 3
Gheyath M. Othman
 
PHP Workshop Notes
PHP Workshop NotesPHP Workshop Notes
PHP Workshop Notes
Pamela Fox
 
Php Crash Course
Php Crash CoursePhp Crash Course
Php Crash Course
mussawir20
 
Php mysql
Php mysqlPhp mysql
Php mysql
Ajit Yadav
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
Tiji Thomas
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
Digital Insights - Digital Marketing Agency
 
Unit 1 php_basics
Unit 1 php_basicsUnit 1 php_basics
Unit 1 php_basics
Kumar
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
Nidhi mishra
 
Php
PhpPhp
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
SHARANBAJWA
 

What's hot (18)

Php
PhpPhp
Php
 
Php advance
Php advancePhp advance
Php advance
 
php
phpphp
php
 
PHP NOTES FOR BEGGINERS
PHP NOTES FOR BEGGINERSPHP NOTES FOR BEGGINERS
PHP NOTES FOR BEGGINERS
 
PHP Tutorials
PHP TutorialsPHP Tutorials
PHP Tutorials
 
Php1
Php1Php1
Php1
 
What Is Php
What Is PhpWhat Is Php
What Is Php
 
Php introduction
Php introductionPhp introduction
Php introduction
 
Web Development Course: PHP lecture 3
Web Development Course: PHP lecture 3Web Development Course: PHP lecture 3
Web Development Course: PHP lecture 3
 
PHP Workshop Notes
PHP Workshop NotesPHP Workshop Notes
PHP Workshop Notes
 
Php Crash Course
Php Crash CoursePhp Crash Course
Php Crash Course
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
 
Unit 1 php_basics
Unit 1 php_basicsUnit 1 php_basics
Unit 1 php_basics
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Php
PhpPhp
Php
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 

Viewers also liked

php lesson 1
php lesson 1php lesson 1
php lesson 1
Kamar Blbel
 
New Perspectives: Access.06
New Perspectives: Access.06New Perspectives: Access.06
New Perspectives: Access.06
Anna Stirling
 
PHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet SolutionPHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet Solution
Mazenetsolution
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Jussi Pohjolainen
 
PHP Project PPT
PHP Project PPTPHP Project PPT
PHP Project PPT
Pankil Agrawal
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Bradley Holt
 

Viewers also liked (6)

php lesson 1
php lesson 1php lesson 1
php lesson 1
 
New Perspectives: Access.06
New Perspectives: Access.06New Perspectives: Access.06
New Perspectives: Access.06
 
PHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet SolutionPHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet Solution
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
PHP Project PPT
PHP Project PPTPHP Project PPT
PHP Project PPT
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 

Similar to Php basics

Php
PhpPhp
Php
PhpPhp
PHP.pptx is the Best Explanation of ppts
PHP.pptx is the Best Explanation of pptsPHP.pptx is the Best Explanation of ppts
PHP.pptx is the Best Explanation of ppts
AkhileshPansare
 
Php1(2)
Php1(2)Php1(2)
Php1(2)
Reka
 
Php notes
Php notesPhp notes
Php notes
Muthuganesh S
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHP
wahidullah mudaser
 
Php1
Php1Php1
Php1
Php1Php1
Php1
Php1Php1
Basic of PHP
Basic of PHPBasic of PHP
Basic of PHP
Nisa Soomro
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
Taha Malampatti
 
1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master
jeeva indra
 
Php
PhpPhp
PHP
 PHP PHP
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
tutorialsruby
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
tutorialsruby
 
Programming in PHP Course Material BCA 6th Semester
Programming in PHP Course Material BCA 6th SemesterProgramming in PHP Course Material BCA 6th Semester
Programming in PHP Course Material BCA 6th Semester
SanthiNivas
 
Php ppt
Php pptPhp ppt
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_master
PrinceGuru MS
 
Introduction to PHP.ppt
Introduction to PHP.pptIntroduction to PHP.ppt
Introduction to PHP.ppt
SanthiNivas
 

Similar to Php basics (20)

Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
PHP.pptx is the Best Explanation of ppts
PHP.pptx is the Best Explanation of pptsPHP.pptx is the Best Explanation of ppts
PHP.pptx is the Best Explanation of ppts
 
Php1(2)
Php1(2)Php1(2)
Php1(2)
 
Php notes
Php notesPhp notes
Php notes
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHP
 
Php1
Php1Php1
Php1
 
Php1
Php1Php1
Php1
 
Php1
Php1Php1
Php1
 
Basic of PHP
Basic of PHPBasic of PHP
Basic of PHP
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master
 
Php
PhpPhp
Php
 
PHP
 PHP PHP
PHP
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
 
Programming in PHP Course Material BCA 6th Semester
Programming in PHP Course Material BCA 6th SemesterProgramming in PHP Course Material BCA 6th Semester
Programming in PHP Course Material BCA 6th Semester
 
Php ppt
Php pptPhp ppt
Php ppt
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_master
 
Introduction to PHP.ppt
Introduction to PHP.pptIntroduction to PHP.ppt
Introduction to PHP.ppt
 

More from sagaroceanic11

Module 21 investigative reports
Module 21 investigative reportsModule 21 investigative reports
Module 21 investigative reportssagaroceanic11
 
Module 20 mobile forensics
Module 20 mobile forensicsModule 20 mobile forensics
Module 20 mobile forensicssagaroceanic11
 
Module 19 tracking emails and investigating email crimes
Module 19 tracking emails and investigating email crimesModule 19 tracking emails and investigating email crimes
Module 19 tracking emails and investigating email crimes
sagaroceanic11
 
Module 18 investigating web attacks
Module 18 investigating web attacksModule 18 investigating web attacks
Module 18 investigating web attacks
sagaroceanic11
 
Module 17 investigating wireless attacks
Module 17 investigating wireless attacksModule 17 investigating wireless attacks
Module 17 investigating wireless attacks
sagaroceanic11
 
Module 04 digital evidence
Module 04 digital evidenceModule 04 digital evidence
Module 04 digital evidence
sagaroceanic11
 
Module 03 searching and seizing computers
Module 03 searching and seizing computersModule 03 searching and seizing computers
Module 03 searching and seizing computers
sagaroceanic11
 
Module 01 computer forensics in todays world
Module 01 computer forensics in todays worldModule 01 computer forensics in todays world
Module 01 computer forensics in todays world
sagaroceanic11
 
Virtualisation with v mware
Virtualisation with v mwareVirtualisation with v mware
Virtualisation with v mware
sagaroceanic11
 
Virtualisation overview
Virtualisation overviewVirtualisation overview
Virtualisation overview
sagaroceanic11
 
Virtualisation basics
Virtualisation basicsVirtualisation basics
Virtualisation basics
sagaroceanic11
 
Introduction to virtualisation
Introduction to virtualisationIntroduction to virtualisation
Introduction to virtualisation
sagaroceanic11
 
6 service operation
6 service operation6 service operation
6 service operation
sagaroceanic11
 
5 service transition
5 service transition5 service transition
5 service transition
sagaroceanic11
 
4 service design
4 service design4 service design
4 service design
sagaroceanic11
 
3 service strategy
3 service strategy3 service strategy
3 service strategy
sagaroceanic11
 
2 the service lifecycle
2 the service lifecycle2 the service lifecycle
2 the service lifecycle
sagaroceanic11
 
1 introduction to itil v[1].3
1 introduction to itil v[1].31 introduction to itil v[1].3
1 introduction to itil v[1].3
sagaroceanic11
 
Visual studio 2008 overview
Visual studio 2008 overviewVisual studio 2008 overview
Visual studio 2008 overview
sagaroceanic11
 
Vb introduction.
Vb introduction.Vb introduction.
Vb introduction.
sagaroceanic11
 

More from sagaroceanic11 (20)

Module 21 investigative reports
Module 21 investigative reportsModule 21 investigative reports
Module 21 investigative reports
 
Module 20 mobile forensics
Module 20 mobile forensicsModule 20 mobile forensics
Module 20 mobile forensics
 
Module 19 tracking emails and investigating email crimes
Module 19 tracking emails and investigating email crimesModule 19 tracking emails and investigating email crimes
Module 19 tracking emails and investigating email crimes
 
Module 18 investigating web attacks
Module 18 investigating web attacksModule 18 investigating web attacks
Module 18 investigating web attacks
 
Module 17 investigating wireless attacks
Module 17 investigating wireless attacksModule 17 investigating wireless attacks
Module 17 investigating wireless attacks
 
Module 04 digital evidence
Module 04 digital evidenceModule 04 digital evidence
Module 04 digital evidence
 
Module 03 searching and seizing computers
Module 03 searching and seizing computersModule 03 searching and seizing computers
Module 03 searching and seizing computers
 
Module 01 computer forensics in todays world
Module 01 computer forensics in todays worldModule 01 computer forensics in todays world
Module 01 computer forensics in todays world
 
Virtualisation with v mware
Virtualisation with v mwareVirtualisation with v mware
Virtualisation with v mware
 
Virtualisation overview
Virtualisation overviewVirtualisation overview
Virtualisation overview
 
Virtualisation basics
Virtualisation basicsVirtualisation basics
Virtualisation basics
 
Introduction to virtualisation
Introduction to virtualisationIntroduction to virtualisation
Introduction to virtualisation
 
6 service operation
6 service operation6 service operation
6 service operation
 
5 service transition
5 service transition5 service transition
5 service transition
 
4 service design
4 service design4 service design
4 service design
 
3 service strategy
3 service strategy3 service strategy
3 service strategy
 
2 the service lifecycle
2 the service lifecycle2 the service lifecycle
2 the service lifecycle
 
1 introduction to itil v[1].3
1 introduction to itil v[1].31 introduction to itil v[1].3
1 introduction to itil v[1].3
 
Visual studio 2008 overview
Visual studio 2008 overviewVisual studio 2008 overview
Visual studio 2008 overview
 
Vb introduction.
Vb introduction.Vb introduction.
Vb introduction.
 

Recently uploaded

The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
christinelarrosa
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Ukraine
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
Enterprise Knowledge
 
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
Fwdays
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
Fwdays
 
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdfLee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
leebarnesutopia
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
DanBrown980551
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptxAI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
Sunil Jagani
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's TipsGetting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
ScyllaDB
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
christinelarrosa
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 

Recently uploaded (20)

The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
 
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
 
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdfLee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptxAI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's TipsGetting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 

Php basics

  • 2.  PHP stands for Hypertext Preprocessor and is a server-side language.  This means that the script is run on your web server, not on the user's browser, so you do not need to worry about compatibility issues.  PHP is relatively new (compared to languages such as Perl (CGI) and Java) but is quickly becomming one of the most popular scripting languages on the internet. WHAT IS PHP?
  • 3. PHP.INI  The php.ini file is a special file for suPHP (pronounced sue-p-h-p).  The php.ini file is where you declare changes to your PHP settings. You can edit the existing php.ini, or create a new text file in any subdirectory and name it php.ini.  Some common changes that you must make when moving from non-secure php environment to suPHP : For example, if your site had these settings in a .htaccess file: php_flag upload_max_filesize 10M php_value post_max_size 10M php_value max_execution_time 30
  • 4. PHP SYNTAX  A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the document.  On servers with shorthand support enabled you can start a scripting block with <? and end with ?>.  For maximum compatibility, we use the standard form (<?php) rather than the shorthand form.
  • 5. PHP VARIABLES  A variable is used to store information, like text strings, numbers or arrays.  When a variable is declared, it can be used over and over again in your script.  All variables in PHP start with a $ sign symbol.  The declaration of php variables is : $var_name = value;
  • 6. PHP STRINGS  String variables are used for values that contains characters.  After we create a string we can manipulate it. A string can be used directly in a function or it can be stored in a variable.  The declaration of a string looks like this : $my_string = “ABSASDFSDF”;
  • 7. PHP OPERATORS  In all programming languages, operators are used to manipulate or perform operations on variables and values.  There are many operators used in PHP, so we have separated them into the following categories to make it easier to learn them all. !) Assignment Operators 2) Arithmetic Operators 3) Comparison Operators 4) String Operators 5) Combination Arithmetic & Assignment Operators
  • 8. ASSIGNMENT OPERATOR  Assignment operators are used to set a variable equal to a value or set a variable to another variable's value. Such an assignment of value is done with the "=", or equal character. Example: $my_var = 4; $another_var = $my_var;  Now both $my_var and $another_var contain the value 4. Assignments can also be used in conjunction with arithmetic operators.
  • 9. ARITHMETIC OPERATOR  The arithmetic operators in php are as follows : OPERATOR MEANING + Addition - Subtraction * Muktiplication / Division % Modulus (Division remainder) ++ Increment -- Decrement
  • 10. COMPARISON OPERATOR  Comparisons are used to check the relationship between variables and/or values. If you would like to see a simple example of a comparison operator in action, check out our If Statement Lesson. Comparison operators are used inside conditional statements and evaluate to either true or false. Here are the most important comparison operators of PHP.  The comparison operators in php are : == means Equals to != means Not equal to < means Less than > means Greater than <= means Less than or Equal to >= means Greater than or equal to
  • 11. STRING OPERATORS  The operator “.” is the string operator used in PHP.  The string operator is used to concatenate two strings.
  • 12. COMBINATION ARITHMETIC AND ASSIGNMENT OPERATOR  It is a combination of assignment and arithmetic operators.  The combination of arithmetic and assignment operators include ; += means Plus eqals -= means Minus equals *= means Multiply equals /= means Divide equals %= means Modulo equals .= means Concatenate equals
  • 13. PHP ECHO  The echo() function outputs one or more strings.  It can output all types of data and multiple outputs can be made with only one echo () command.  For example <?php echo “HI”; ?> Prints the string “HI”.
  • 14. PHP GET  The GET method sends the encoded user information appended to the page request. The page and the encoded information are separated by the ? Character.  The data sent by GET method can be accessed using QUERY_STRING environment variable.  The PHP provides $_GET associative array to access all the sent information using GET method.
  • 15. PHP POST  The POST method transfers information via HTTP headers. The information is encoded as described in case of GET method and put into a header called QUERY_STRING.  The POST method does not have any restriction on data size to be sent.  The data sent by POST method goes through HTTP header so security depends on HTTP protocol. By using Secure HTTP you can make sure that your information is secure.  The PHP provides $_POST associative array to access all the sent information using GET method.
  • 16. PHP FILES  Manipulating files is a basic necessity for serious programmers and PHP gives you a great deal of tools for creating, uploading, and editing files.  PHP files deals with read, write, append, truncate, and uploading files.
  • 17. CREATE FILE  In PHP, a file is created using a command that is also used to open files.  In PHP the fopen function is used to open files. However, it can also create a file if it does not find the file specified in the function call. So if you use fopen on a file that does not exist, it will create it, given that you open the file for writing or appending (more on this later).  The fopen function needs two important pieces of information to operate correctly. First, we must supply it with the name of the file that we want it to open. Secondly, we must tell the function what we plan on doing with that file (i.e. read from the file, write information, etc).  The code for Creating a file is as follows : $ourFileName = "testFile.txt"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fclose($ourFileHandle);
  • 18. OPEN FILE  The fopen function is used to open a file.  There are different modes to open a file. They are : (i) Read 'r' : - Open a file for read only use. The file pointer begins at the front of the file. (ii) Write 'w' :- Open a file for write only use. In addition, the data in the file is erased and you will begin writing data at the beginning of the file. This is also called truncating a file, which we will talk about more in a later lesson. The file pointer begins at the start of the file. (iii) Append 'a' :- Opens and writes to the end of the file or creates a new file if it doesn't exist
  • 19. CLOSE FILE  The fclose function is used to close a file in php.  The genral structure for closing a file is : $ourFileName = "testFile.txt"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fclose($ourFileHandle);
  • 20. PHP SESSIONS  In PHP, a "session" is the time that a user spends on a web site.  A PHP Session allows certain data to be preserved across an access span, by assigning a unique ID called "Session ID", to each visitor to the site.  This Session ID can be stored as a cookie at the client end, or passed through a URL.  To start a new session and to destroy a session, The following code must be used : <?php session_start(); //YOUR CODE HERE session_destroy(); ?>
  • 21. PHP COOKIES  Cookies have been around for quite some time on the internet. They were invented to allow webmaster's to store information about the user and their visit on the user's computer.  When you create a cookie, using the function setcookie, you must specify three arguments. These arguments are setcookie(name, value, expiration): 1. name: The name of your cookie. You will use this name to later retrieve your cookie, so don't forget it! 2. value: The value that is stored in your cookie. Common values are username(string) and last visit(date). 3. expiration: The date when the cookie will expire and be deleted. If you do not set this expiration date, then it will be treated as a session cookie and be removed when the browser is restarted.
  • 22. PHP COOKIES  The following sample code is used to retrieve a cookie : <?php if(isset($_COOKIE['lastVisit'])) $visit = $_COOKIE['lastVisit']; else echo "You've got some stale cookies!"; echo "Your last visit was - ". $visit; ?>