SlideShare a Scribd company logo
PHP
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 &quot;=&quot;, 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 = &quot;testFile.txt&quot;; $ourFileHandle = fopen($ourFileName, 'w') or die(&quot;can't open file&quot;); 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 = &quot;testFile.txt&quot;; $ourFileHandle = fopen($ourFileName, 'w') or die(&quot;can't open file&quot;); fclose($ourFileHandle);
PHP SESSIONS In PHP, a &quot;session&quot; 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 &quot;Session ID&quot;, 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 (Contd...) The following sample code is used to  retrieve a cookie : <?php if(isset($_COOKIE['lastVisit']))   $visit = $_COOKIE['lastVisit'];  else   echo &quot;You've got some stale cookies!&quot;; echo &quot;Your last visit was - &quot;. $visit; ?>
THANK YOU

More Related Content

What's hot (18)

PDF
Web Development Course: PHP lecture 1
Gheyath M. Othman
 
PPTX
PHP 2
Richa Goel
 
PPT
What Is Php
AVC
 
PPSX
Php and MySQL
Tiji Thomas
 
PPTX
Php
Richa Goel
 
PPT
Control Structures In Php 2
Digital Insights - Digital Marketing Agency
 
PPTX
Php Unit 1
team11vgnt
 
PDF
PHP Loops and PHP Forms
M.Zalmai Rahmani
 
PPT
Beginners PHP Tutorial
alexjones89
 
PDF
Web Development Course: PHP lecture 3
Gheyath M. Othman
 
PPTX
Php Tutorial
pratik tambekar
 
PPT
PHP
sometech
 
PPT
Open Source Package PHP & MySQL
kalaisai
 
PPT
PHP Workshop Notes
Pamela Fox
 
PDF
Php a dynamic web scripting language
Elmer Concepcion Jr.
 
Web Development Course: PHP lecture 1
Gheyath M. Othman
 
PHP 2
Richa Goel
 
What Is Php
AVC
 
Php and MySQL
Tiji Thomas
 
Control Structures In Php 2
Digital Insights - Digital Marketing Agency
 
Php Unit 1
team11vgnt
 
PHP Loops and PHP Forms
M.Zalmai Rahmani
 
Beginners PHP Tutorial
alexjones89
 
Web Development Course: PHP lecture 3
Gheyath M. Othman
 
Php Tutorial
pratik tambekar
 
Open Source Package PHP & MySQL
kalaisai
 
PHP Workshop Notes
Pamela Fox
 
Php a dynamic web scripting language
Elmer Concepcion Jr.
 

Similar to Php (20)

PPTX
Day1
IRWAA LLC
 
PPT
Php mysql ppt
Karmatechnologies Pvt. Ltd.
 
PDF
basic concept of php(Gunikhan sonowal)
Guni Sonow
 
PPTX
An introduction to PHP : PHP and Using PHP, Variables Program control and Bui...
Vigneshkumar Ponnusamy
 
PPTX
introduction to php and its uses in daily
vishal choudhary
 
PPTX
PHP2An introduction to Gnome.pptx.j.pptx
JAYAVARSHINIJR
 
PPT
Learning of Php and My SQL Tutorial | For Beginners
Ratnesh Pandey
 
PPT
Php Tutorial | Introduction Demo | Basics
Shubham Kumar Singh
 
ODP
PHP BASIC PRESENTATION
krutitrivedi
 
PPT
php 1
tumetr1
 
PPTX
Php basics
Jamshid Hashimi
 
PPT
Intro to PHP for Students and professionals
cuyak
 
PPTX
Ch1(introduction to php)
Chhom Karath
 
PDF
Programming in PHP Course Material BCA 6th Semester
SanthiNivas
 
ODP
Php1(2)
Reka
 
PPT
Php mysql
Alebachew Zewdu
 
Day1
IRWAA LLC
 
basic concept of php(Gunikhan sonowal)
Guni Sonow
 
An introduction to PHP : PHP and Using PHP, Variables Program control and Bui...
Vigneshkumar Ponnusamy
 
introduction to php and its uses in daily
vishal choudhary
 
PHP2An introduction to Gnome.pptx.j.pptx
JAYAVARSHINIJR
 
Learning of Php and My SQL Tutorial | For Beginners
Ratnesh Pandey
 
Php Tutorial | Introduction Demo | Basics
Shubham Kumar Singh
 
PHP BASIC PRESENTATION
krutitrivedi
 
php 1
tumetr1
 
Php basics
Jamshid Hashimi
 
Intro to PHP for Students and professionals
cuyak
 
Ch1(introduction to php)
Chhom Karath
 
Programming in PHP Course Material BCA 6th Semester
SanthiNivas
 
Php1(2)
Reka
 
Php mysql
Alebachew Zewdu
 
Ad

More from TSUBHASHRI (6)

PPT
Ajax
TSUBHASHRI
 
PPT
Php
TSUBHASHRI
 
PPT
Php
TSUBHASHRI
 
PPT
Web 2.0
TSUBHASHRI
 
PPT
Linuxppt
TSUBHASHRI
 
PPT
Mysql
TSUBHASHRI
 
Web 2.0
TSUBHASHRI
 
Linuxppt
TSUBHASHRI
 
Mysql
TSUBHASHRI
 
Ad

Recently uploaded (20)

PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPTX
Designing Production-Ready AI Agents
Kunal Rai
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Biography of Daniel Podor.pdf
Daniel Podor
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Designing Production-Ready AI Agents
Kunal Rai
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 

Php

  • 1. PHP
  • 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 &quot;=&quot;, 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 = &quot;testFile.txt&quot;; $ourFileHandle = fopen($ourFileName, 'w') or die(&quot;can't open file&quot;); 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 = &quot;testFile.txt&quot;; $ourFileHandle = fopen($ourFileName, 'w') or die(&quot;can't open file&quot;); fclose($ourFileHandle);
  • 20. PHP SESSIONS In PHP, a &quot;session&quot; 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 &quot;Session ID&quot;, 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 (Contd...) The following sample code is used to retrieve a cookie : <?php if(isset($_COOKIE['lastVisit'])) $visit = $_COOKIE['lastVisit']; else echo &quot;You've got some stale cookies!&quot;; echo &quot;Your last visit was - &quot;. $visit; ?>