SlideShare a Scribd company logo
1
PHP - TUTORIAL
2
Introduction
● What is “PHP” ?
– PHP is an HTML-embedded scripting language.
– PHP is a server side scripting language.
– PHP syntax is borrowed from C, Java and Perl with a couple
of unique PHP-specific features thrown in.
– The goal of the language is to allow web developers to write
dynamically generated pages quickly.
3
Introduction
● What PHP do?
– When someone visits your PHP webpage, your web server
processes the PHP code.
– It then sees which parts it needs to show to visitors(content
and pictures) and hides the other stuff (file operations, math
calculations, etc.) then translates your PHP into HTML.
– After the translation into HTML, it sends the webpage to
your visitor's web browser.
4
Introduction
5
Introduction
● What you need to learn PHP?
– Software
● Web server (Apache/Nginx/IIS)
● PHP itself
● PHP code editor (notepad++,context, etc.)
● Database Server (MySQL/SQLite/SQLServer)
– User skill
● Know HTML syntax
● Basic programming knowledge (not necesary)
6
Introduction
● Characteristic of PHP
– Simplicity
– Efficiency
– Security
– Flexibility
– Familiarity
7
Introduction
● Common use of PHP
– Performs system functions, i.e. from files on a system it can
create, open, read, write, and close them.
– Can handle forms, i.e. gather data from files, save data to a file,
thru email you can send data, return data to the user.
– Add, delete, modify elements within your database thru PHP.
– Access cookies variables and set cookies.
– Using PHP, you can restrict users to access some pages of your
website.
– It can encrypt data.
8
Installing PHP
● For Microsoft Windows user
– Use XAMPP/WAMPP for all in one web server
(PHP, MySQL, Apache, phpMyAdmin)
– Use Microsoft web server (IIS)
● For Linux user
– Refers to your linux distribution repository or install one by
one (PHP, MySQL, Apache, phpMyAdmin)
– Using lamp package
9
How to save PHP files?
● Always save the file with a .php extension instead of .html
● Do not use word processor applications to create a php files.
● Always use pure text editor such as notepad++, context, or
specific IDE for PHP (komodo, crimson, aptana studio, etc.)
10
PHP - Syntax
● What is “Syntax” ?
– The rules that must be followed to write properly structured
code.
● Standard syntax of PHP
– <?php
?>
● Non-standard syntax of PHP (not recommended)
– <?
?>
11
PHP - Syntax
● Semicolon
– The semicolon signifies the end of a PHP statement and
should never be forgotten.
● White space
– Whitespace is ignored between PHP statements.
– This means it is OK to have one line of PHP code, then 20
lines of blank space before the next line of PHP code.
– You can also press tab to indent your code and the PHP
interpreter will ignore those spaces as well.
12
Sample of PHP code
<?php
echo "Hello World!";
echo "Hello World!";
?>
Will display in browser:
Hello World!Hello World!
13
PHP Syntax
● Use “ . “ (dot) to combine token
– Token is the smallest part of PHP
● Example
– Numbers (124583)
– Variables
– Constants
● Braces make blocks
if (3 == 2 + 1)
{
echo "Good - I haven't totally";
echo "lost my mind.<br>";
}
14
PHP Syntax
● Commenting in PHP
– Single comment → //
– Multiple/block comment
● /*
Comment1
Comment2
*/
15
PHP Variables
● What is Variables?
– A place in computer memory for storing a value (text/number)
● Variables can, but do not need, to be declared before assignment.
● Variables used before they are assigned have default values.
● PHP does a good job of automatically converting types from one to another when
necessary.
● PHP variables are Perl-like.
● Defining the variable
– $variable_name = Value;
– Example
● $name=”Kris”;
● $midTerm=77;
● $final_grade=”A”;
16
PHP Variables
● Naming conventions
– must start with a letter or underscore "_"
– may only be comprised of alpha-numeric characters and
underscores. a-z, A-Z, 0-9, or _
– Variables with more than one word should be separated with
underscores (ex. $my_variable)
– Variables with more than one word can also be distinguished
with capitalization (ex. $myVariable)
– Php variables are case sensitive !
17
PHP data types
● Integers: are whole numbers, without a decimal point, like 4195.
● Doubles: are floating-point numbers, like 3.14159 or 49.1.
● Booleans: have only two possible values either true or false.
● NULL: is a special type that only has one value: NULL.
● Strings: are sequences of characters, like 'PHP supports string operations.'
● Arrays: are named and indexed collections of other values.
● Objects: are instances of programmer-defined classes, which can package
up both other kinds of values and functions that are specific to the class.
● Resources: are special variables that hold references to resources external
to PHP (such as database connections).
18
Output command
● Echo command
– To send an output to screen, use 'echo' command
– It can be used for variable or even a quotation string
– ex.
<?php
$myString = "Hello!";
echo $myString;
echo "<h5>I love using PHP!</h5>";
?>
19
Echo attention
● Be careful when using HTML code or any other string that
includes quotes
● Use one of the following tactics if your string contains
quotations:
– Don't use quotes inside your string
– Escape your quotes that are within the string with a
backslash. To escape a quote just place a backslash directly
before the quotation mark, i.e. "
– Use single quotes (apostrophes) for quotes inside your string.
20
Echo attention
● Ex.
<?php
echo "<h5 class="specialH5">I love using PHP!</h5>";
echo "<h5 class='specialH5'>I love using PHP!</h5>";
?>
21
PHP Operator
Operator Meaning Example
+ Addition 3 + 5
- Subtraction 4 - 2
* Multiplication 5 * 6
/ Division 8 / 2
% Modulus 3 % 2
Assignment Operator → =
Arithmetic Operator
22
Example
$addition = 3 + 5;
$subtraction = 4 - 2;
$multiplication = 5 * 6;
$division = 8 / 2;
$modulus = 3 % 2;
echo "Perform addition: 3 + 5 = ".$addition."<br />";
echo "Perform subtraction: 4 - 2 = ".$subtraction."<br />";
echo "Perform multiplication: 5 * 6 = ".$multiplication."<br />";
echo "Perform division: 8 / 2 = ".$division."<br />";
echo "Perform modulus: 3 % 2 = " . $modulus
. ". Modulus is the remainder after the division operation has been performed.
In this case it was 3 / 2, which has a remainder of 1.";
23
PHP Operator
● Comparison Operator
Operator Meaning Example
== Equal to $x == $y
!= Not equal to $x != $y
< Less then $x < $y
> Greater then $x > $y
<= Less or equal to $x <= $y
>= Greater or equal to $x >= $y
24
PHP Operator
● String operator → “ . “ (dot)
– The period is the concatenation operator for strings
● Ex.
$a = “Kris”;
$b = “John”;
echo $a . “ and “ . $b;
25
PHP Operator
● Combination between assignment and arithmetic operator
Operator Meaning Example Equivalent
+= Plus equals $x += 3 $x = $x+3;
-= Minus equals $x -= 3 $x = $x-3;
*= Multiply equals $x *= 3 $x = $x*3;
/= Divide equals $x /= 3 $x = $x/3;
%= Modulo equals $x %= 2 $x = $x%2;
.= Concatenate equals $x .=”AB” $x=$x.”AB”;
26
PHP Operator
● pre/post-increment/decrement
● Ex.
$x = 4;
echo "The value of x with post-plusplus = " . $x++;
echo "<br /> The value of x after the post-plusplus is " . $x;
$x = 4;
echo "<br />The value of x with with pre-plusplus = " . ++$x;
echo "<br /> The value of x after the pre-plusplus is " . $x;
27
PHP If Statement
● IF
– IF <expression>
statement;
● IF … ELSE
– IF <expression>
statement_true;
ELSE
statement_false;
28
Excercise
● Show “Hello, John.” in the browser
● Show “I'm learning PHP” in the browser
● Show “Twinkle, Twinkle little star.” in the browser
● Show “What goes around, comes around.” (use variable to print 'around' word)
● Create the following variables:
– $x=10
– $y=5
● Write php code to print out the following
– 10 + 5 = 15
– 10 – 5 = 5
– 10 * 5 = 50
– 10 / 5 = 2
– 10 % 5 = 0
29
Excercise
● Create php script that print like the following:
– Value is now 8.
– Add 2. Value is now 10.
– Subtract 4. Value is now 6.
– Multiply by 5. Value is now 30.
– Divide by 3. Value is now 10.
– Increment value by one. Value is now 11.
– Decrement value by one. Value is now 10.
Hint: use arithmetic-assignment operator

More Related Content

What's hot (20)

Php(report)
Php(report)Php(report)
Php(report)
Yhannah
 
Php introduction and configuration
Php introduction and configurationPhp introduction and configuration
Php introduction and configuration
Vijay Kumar Verma
 
Basic PHP
Basic PHPBasic PHP
Basic PHP
Todd Barber
 
PHP Comprehensive Overview
PHP Comprehensive OverviewPHP Comprehensive Overview
PHP Comprehensive Overview
Mohamed Loey
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
Arjun Shanka
 
Php i basic chapter 3
Php i basic chapter 3Php i basic chapter 3
Php i basic chapter 3
Muhamad Al Imran
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
Alokin Software Pvt Ltd
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
Digital Insights - Digital Marketing Agency
 
Php Unit 1
Php Unit 1Php Unit 1
Php Unit 1
team11vgnt
 
PHP slides
PHP slidesPHP slides
PHP slides
Farzad Wadia
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
KIRAN KUMAR SILIVERI
 
PHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginnersPHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginners
Mohammed Mushtaq Ahmed
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
pratik tambekar
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
Nidhi mishra
 
PHP
PHPPHP
PHP
sometech
 
01 Php Introduction
01 Php Introduction01 Php Introduction
01 Php Introduction
Geshan Manandhar
 
PHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet SolutionPHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet Solution
Mazenetsolution
 
Php tutorial
Php  tutorialPhp  tutorial
Php tutorial
Computer Hardware & Trouble shooting
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
Taha Malampatti
 
PHP Basic & Variables
PHP Basic & VariablesPHP Basic & Variables
PHP Basic & Variables
M.Zalmai Rahmani
 

Viewers also liked (7)

Θέμα Δράσης: «Παγκόσμια Ημέρα Ατόμων με Ειδικές Ανάγκες»
Θέμα Δράσης: «Παγκόσμια Ημέρα Ατόμων με Ειδικές Ανάγκες»Θέμα Δράσης: «Παγκόσμια Ημέρα Ατόμων με Ειδικές Ανάγκες»
Θέμα Δράσης: «Παγκόσμια Ημέρα Ατόμων με Ειδικές Ανάγκες»
Σπύρος Κυριαζίδης
 
United kingdom
United kingdomUnited kingdom
United kingdom
djowens3
 
United kingdom
United kingdomUnited kingdom
United kingdom
djowens3
 
Php modul-3
Php modul-3Php modul-3
Php modul-3
Kristophorus Hadiono
 
Παγκόσμια ημέρα υγροτόπων
Παγκόσμια ημέρα υγροτόπωνΠαγκόσμια ημέρα υγροτόπων
Παγκόσμια ημέρα υγροτόπων
Σπύρος Κυριαζίδης
 
Php modul-2
Php modul-2Php modul-2
Php modul-2
Kristophorus Hadiono
 
Aνακύκλωση και παιχνίδια
Aνακύκλωση και παιχνίδια Aνακύκλωση και παιχνίδια
Aνακύκλωση και παιχνίδια
Σπύρος Κυριαζίδης
 
Ad

Similar to Php modul-1 (20)

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
 
php 1
php 1php 1
php 1
tumetr1
 
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Muhamad Al Imran
 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Muhamad Al Imran
 
Php essentials
Php essentialsPhp essentials
Php essentials
sagaroceanic11
 
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
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdf
AAFREEN SHAIKH
 
Php web development
Php web developmentPhp web development
Php web development
Ramesh Gupta
 
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
 
Chap 4 PHP.pdf
Chap 4 PHP.pdfChap 4 PHP.pdf
Chap 4 PHP.pdf
HASENSEID
 
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
 
Unit 5-PHP Declaring variables, data types, array, string, operators, Expres...
Unit 5-PHP  Declaring variables, data types, array, string, operators, Expres...Unit 5-PHP  Declaring variables, data types, array, string, operators, Expres...
Unit 5-PHP Declaring variables, data types, array, string, operators, Expres...
DRambabu3
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Devshri Pandya
 
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Muhamad Al Imran
 
Php tutorialw3schools
Php tutorialw3schoolsPhp tutorialw3schools
Php tutorialw3schools
rasool noorpour
 
Php
PhpPhp
Php
Richa Goel
 
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
anshkhurana01
 
Php unit i
Php unit iPhp unit i
Php unit i
BagavathiLakshmi
 
Php
PhpPhp
Php
Rajkiran Mummadi
 
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
 
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Muhamad Al Imran
 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Muhamad Al Imran
 
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
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdf
AAFREEN SHAIKH
 
Php web development
Php web developmentPhp web development
Php web development
Ramesh Gupta
 
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
 
Chap 4 PHP.pdf
Chap 4 PHP.pdfChap 4 PHP.pdf
Chap 4 PHP.pdf
HASENSEID
 
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
 
Unit 5-PHP Declaring variables, data types, array, string, operators, Expres...
Unit 5-PHP  Declaring variables, data types, array, string, operators, Expres...Unit 5-PHP  Declaring variables, data types, array, string, operators, Expres...
Unit 5-PHP Declaring variables, data types, array, string, operators, Expres...
DRambabu3
 
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Muhamad Al Imran
 
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
anshkhurana01
 
Ad

Recently uploaded (20)

Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto CertificateCybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
VICTOR MAESTRE RAMIREZ
 
DevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical PodcastDevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical Podcast
Chris Wahl
 
Jira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : IntroductionJira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : Introduction
Ravi Teja
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
7 Salesforce Data Cloud Best Practices.pdf
7 Salesforce Data Cloud Best Practices.pdf7 Salesforce Data Cloud Best Practices.pdf
7 Salesforce Data Cloud Best Practices.pdf
Minuscule Technologies
 
Trends Report: Artificial Intelligence (AI)
Trends Report: Artificial Intelligence (AI)Trends Report: Artificial Intelligence (AI)
Trends Report: Artificial Intelligence (AI)
Brian Ahier
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
MCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
MCP vs A2A vs ACP: Choosing the Right Protocol | BluebashMCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
MCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
Bluebash
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Compliance-as-a-Service document pdf text
Compliance-as-a-Service document pdf textCompliance-as-a-Service document pdf text
Compliance-as-a-Service document pdf text
Earthling security
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
Securiport - A Border Security Company
Securiport  -  A Border Security CompanySecuriport  -  A Border Security Company
Securiport - A Border Security Company
Securiport
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto CertificateCybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
VICTOR MAESTRE RAMIREZ
 
DevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical PodcastDevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical Podcast
Chris Wahl
 
Jira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : IntroductionJira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : Introduction
Ravi Teja
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
7 Salesforce Data Cloud Best Practices.pdf
7 Salesforce Data Cloud Best Practices.pdf7 Salesforce Data Cloud Best Practices.pdf
7 Salesforce Data Cloud Best Practices.pdf
Minuscule Technologies
 
Trends Report: Artificial Intelligence (AI)
Trends Report: Artificial Intelligence (AI)Trends Report: Artificial Intelligence (AI)
Trends Report: Artificial Intelligence (AI)
Brian Ahier
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
MCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
MCP vs A2A vs ACP: Choosing the Right Protocol | BluebashMCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
MCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
Bluebash
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Compliance-as-a-Service document pdf text
Compliance-as-a-Service document pdf textCompliance-as-a-Service document pdf text
Compliance-as-a-Service document pdf text
Earthling security
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
Securiport - A Border Security Company
Securiport  -  A Border Security CompanySecuriport  -  A Border Security Company
Securiport - A Border Security Company
Securiport
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 

Php modul-1

  • 2. 2 Introduction ● What is “PHP” ? – PHP is an HTML-embedded scripting language. – PHP is a server side scripting language. – PHP syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. – The goal of the language is to allow web developers to write dynamically generated pages quickly.
  • 3. 3 Introduction ● What PHP do? – When someone visits your PHP webpage, your web server processes the PHP code. – It then sees which parts it needs to show to visitors(content and pictures) and hides the other stuff (file operations, math calculations, etc.) then translates your PHP into HTML. – After the translation into HTML, it sends the webpage to your visitor's web browser.
  • 5. 5 Introduction ● What you need to learn PHP? – Software ● Web server (Apache/Nginx/IIS) ● PHP itself ● PHP code editor (notepad++,context, etc.) ● Database Server (MySQL/SQLite/SQLServer) – User skill ● Know HTML syntax ● Basic programming knowledge (not necesary)
  • 6. 6 Introduction ● Characteristic of PHP – Simplicity – Efficiency – Security – Flexibility – Familiarity
  • 7. 7 Introduction ● Common use of PHP – Performs system functions, i.e. from files on a system it can create, open, read, write, and close them. – Can handle forms, i.e. gather data from files, save data to a file, thru email you can send data, return data to the user. – Add, delete, modify elements within your database thru PHP. – Access cookies variables and set cookies. – Using PHP, you can restrict users to access some pages of your website. – It can encrypt data.
  • 8. 8 Installing PHP ● For Microsoft Windows user – Use XAMPP/WAMPP for all in one web server (PHP, MySQL, Apache, phpMyAdmin) – Use Microsoft web server (IIS) ● For Linux user – Refers to your linux distribution repository or install one by one (PHP, MySQL, Apache, phpMyAdmin) – Using lamp package
  • 9. 9 How to save PHP files? ● Always save the file with a .php extension instead of .html ● Do not use word processor applications to create a php files. ● Always use pure text editor such as notepad++, context, or specific IDE for PHP (komodo, crimson, aptana studio, etc.)
  • 10. 10 PHP - Syntax ● What is “Syntax” ? – The rules that must be followed to write properly structured code. ● Standard syntax of PHP – <?php ?> ● Non-standard syntax of PHP (not recommended) – <? ?>
  • 11. 11 PHP - Syntax ● Semicolon – The semicolon signifies the end of a PHP statement and should never be forgotten. ● White space – Whitespace is ignored between PHP statements. – This means it is OK to have one line of PHP code, then 20 lines of blank space before the next line of PHP code. – You can also press tab to indent your code and the PHP interpreter will ignore those spaces as well.
  • 12. 12 Sample of PHP code <?php echo "Hello World!"; echo "Hello World!"; ?> Will display in browser: Hello World!Hello World!
  • 13. 13 PHP Syntax ● Use “ . “ (dot) to combine token – Token is the smallest part of PHP ● Example – Numbers (124583) – Variables – Constants ● Braces make blocks if (3 == 2 + 1) { echo "Good - I haven't totally"; echo "lost my mind.<br>"; }
  • 14. 14 PHP Syntax ● Commenting in PHP – Single comment → // – Multiple/block comment ● /* Comment1 Comment2 */
  • 15. 15 PHP Variables ● What is Variables? – A place in computer memory for storing a value (text/number) ● Variables can, but do not need, to be declared before assignment. ● Variables used before they are assigned have default values. ● PHP does a good job of automatically converting types from one to another when necessary. ● PHP variables are Perl-like. ● Defining the variable – $variable_name = Value; – Example ● $name=”Kris”; ● $midTerm=77; ● $final_grade=”A”;
  • 16. 16 PHP Variables ● Naming conventions – must start with a letter or underscore "_" – may only be comprised of alpha-numeric characters and underscores. a-z, A-Z, 0-9, or _ – Variables with more than one word should be separated with underscores (ex. $my_variable) – Variables with more than one word can also be distinguished with capitalization (ex. $myVariable) – Php variables are case sensitive !
  • 17. 17 PHP data types ● Integers: are whole numbers, without a decimal point, like 4195. ● Doubles: are floating-point numbers, like 3.14159 or 49.1. ● Booleans: have only two possible values either true or false. ● NULL: is a special type that only has one value: NULL. ● Strings: are sequences of characters, like 'PHP supports string operations.' ● Arrays: are named and indexed collections of other values. ● Objects: are instances of programmer-defined classes, which can package up both other kinds of values and functions that are specific to the class. ● Resources: are special variables that hold references to resources external to PHP (such as database connections).
  • 18. 18 Output command ● Echo command – To send an output to screen, use 'echo' command – It can be used for variable or even a quotation string – ex. <?php $myString = "Hello!"; echo $myString; echo "<h5>I love using PHP!</h5>"; ?>
  • 19. 19 Echo attention ● Be careful when using HTML code or any other string that includes quotes ● Use one of the following tactics if your string contains quotations: – Don't use quotes inside your string – Escape your quotes that are within the string with a backslash. To escape a quote just place a backslash directly before the quotation mark, i.e. " – Use single quotes (apostrophes) for quotes inside your string.
  • 20. 20 Echo attention ● Ex. <?php echo "<h5 class="specialH5">I love using PHP!</h5>"; echo "<h5 class='specialH5'>I love using PHP!</h5>"; ?>
  • 21. 21 PHP Operator Operator Meaning Example + Addition 3 + 5 - Subtraction 4 - 2 * Multiplication 5 * 6 / Division 8 / 2 % Modulus 3 % 2 Assignment Operator → = Arithmetic Operator
  • 22. 22 Example $addition = 3 + 5; $subtraction = 4 - 2; $multiplication = 5 * 6; $division = 8 / 2; $modulus = 3 % 2; echo "Perform addition: 3 + 5 = ".$addition."<br />"; echo "Perform subtraction: 4 - 2 = ".$subtraction."<br />"; echo "Perform multiplication: 5 * 6 = ".$multiplication."<br />"; echo "Perform division: 8 / 2 = ".$division."<br />"; echo "Perform modulus: 3 % 2 = " . $modulus . ". Modulus is the remainder after the division operation has been performed. In this case it was 3 / 2, which has a remainder of 1.";
  • 23. 23 PHP Operator ● Comparison Operator Operator Meaning Example == Equal to $x == $y != Not equal to $x != $y < Less then $x < $y > Greater then $x > $y <= Less or equal to $x <= $y >= Greater or equal to $x >= $y
  • 24. 24 PHP Operator ● String operator → “ . “ (dot) – The period is the concatenation operator for strings ● Ex. $a = “Kris”; $b = “John”; echo $a . “ and “ . $b;
  • 25. 25 PHP Operator ● Combination between assignment and arithmetic operator Operator Meaning Example Equivalent += Plus equals $x += 3 $x = $x+3; -= Minus equals $x -= 3 $x = $x-3; *= Multiply equals $x *= 3 $x = $x*3; /= Divide equals $x /= 3 $x = $x/3; %= Modulo equals $x %= 2 $x = $x%2; .= Concatenate equals $x .=”AB” $x=$x.”AB”;
  • 26. 26 PHP Operator ● pre/post-increment/decrement ● Ex. $x = 4; echo "The value of x with post-plusplus = " . $x++; echo "<br /> The value of x after the post-plusplus is " . $x; $x = 4; echo "<br />The value of x with with pre-plusplus = " . ++$x; echo "<br /> The value of x after the pre-plusplus is " . $x;
  • 27. 27 PHP If Statement ● IF – IF <expression> statement; ● IF … ELSE – IF <expression> statement_true; ELSE statement_false;
  • 28. 28 Excercise ● Show “Hello, John.” in the browser ● Show “I'm learning PHP” in the browser ● Show “Twinkle, Twinkle little star.” in the browser ● Show “What goes around, comes around.” (use variable to print 'around' word) ● Create the following variables: – $x=10 – $y=5 ● Write php code to print out the following – 10 + 5 = 15 – 10 – 5 = 5 – 10 * 5 = 50 – 10 / 5 = 2 – 10 % 5 = 0
  • 29. 29 Excercise ● Create php script that print like the following: – Value is now 8. – Add 2. Value is now 10. – Subtract 4. Value is now 6. – Multiply by 5. Value is now 30. – Divide by 3. Value is now 10. – Increment value by one. Value is now 11. – Decrement value by one. Value is now 10. Hint: use arithmetic-assignment operator