SlideShare a Scribd company logo
1 of 29
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)
 
Php introduction and configuration
Php introduction and configurationPhp introduction and configuration
Php introduction and configuration
 
Basic PHP
Basic PHPBasic PHP
Basic PHP
 
PHP Comprehensive Overview
PHP Comprehensive OverviewPHP Comprehensive Overview
PHP Comprehensive Overview
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
 
Php i basic chapter 3
Php i basic chapter 3Php i basic chapter 3
Php i basic chapter 3
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
 
Php Unit 1
Php Unit 1Php Unit 1
Php Unit 1
 
PHP slides
PHP slidesPHP slides
PHP slides
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
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
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
PHP
PHPPHP
PHP
 
01 Php Introduction
01 Php Introduction01 Php Introduction
01 Php Introduction
 
PHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet SolutionPHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet Solution
 
Php tutorial
Php  tutorialPhp  tutorial
Php tutorial
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
PHP Basic & Variables
PHP Basic & VariablesPHP Basic & Variables
PHP Basic & Variables
 

Viewers also liked

Viewers also liked (7)

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

Similar to Php modul-1

Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPrinceGuru MS
 
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 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
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPwahidullah 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).pdfAAFREEN SHAIKH
 
Php web development
Php web developmentPhp web development
Php web developmentRamesh 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_masterjeeva indra
 
Chap 4 PHP.pdf
Chap 4 PHP.pdfChap 4 PHP.pdf
Chap 4 PHP.pdfHASENSEID
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPtutorialsruby
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPtutorialsruby
 
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
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to phpAnjan Banda
 

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
 
php 1
php 1php 1
php 1
 
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)
 
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)
 
Php essentials
Php essentialsPhp essentials
Php essentials
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHP
 
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
 
Php web development
Php web developmentPhp web development
Php web development
 
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
 
Chap 4 PHP.pdf
Chap 4 PHP.pdfChap 4 PHP.pdf
Chap 4 PHP.pdf
 
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
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
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)
 
Php tutorialw3schools
Php tutorialw3schoolsPhp tutorialw3schools
Php tutorialw3schools
 
Php
PhpPhp
Php
 
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...
 
Php unit i
Php unit iPhp unit i
Php unit i
 
Php
PhpPhp
Php
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 

Recently uploaded

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

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