SlideShare a Scribd company logo
dfdfd
Php
Php
 multiline
 $txt = "Hello world!";
$x = 5;
$y = 10.5;
echo $txt;
Echo $Txt;
* Variable name must begin with a letter or a
underscore( must not use numeric)
 n is replaced by the newline character
 t is replaced by the tab character
 $ is replaced by the dollar sign itself ($)
 " is replaced by a single double-quote (")
  is replaced by a single backslash ()
Php
 අගය නනොනෙනස්ෙ පෙතී.
 <?php
 define("MINSIZE", 50);
 echo MINSIZE;
 echo constant("MINSIZE"); // same thing as
the previous line
 ?>
<?php
$cars = array("Volvo", "BMW", "Toyota");
echo "I like " . $cars[0] . ", " . $cars[1] . " and " .
$cars[2] . ".";
?>
Syntax
if (condition) {
code to be executed if condition is true;
} else {
code to be executed if condition is false;
}
Example
<?php
$t = 1000;
if ($t < 500) {
echo “Small one";
} else {
echo “Big one";
}
?>
 while (condition is true) {
code to be executed;
}
 <?php
$x = 1;
while($x <= 5) {
echo "The number is: $x <br>";
$x++;
}
?>
 <?php
$x = 0;
while($x < 10) {
if ($x == 4) {
break;
}
echo "The number is: $x <br>";
$x++;
}
?>
 Login using your root (user)
 From the main menu choose Databases
 In the create database field type in a name for
your database
 Click on Users in the main menu.
 Choose the Add User option.
 In the section Login Information - type in
a username, localhost and a password
 GLOBAL privileges apply to ALL databases on
the server ( leave this section BLANK)
 Then click the Add User button
 Click Edit Privileges to assign access to a
specific database of created user
 <?php
$servername = "localhost";
$username = "username";
$password = "password";
// Create connection
$conn = new mysqli($servername, $username,
$password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
 $conn->close();
 $sql = "INSERT INTO MyGuests (firstname,
lastname, email)
VALUES ('John', 'Doe', 'john@example.com')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$sql = "DELETE FROM MyGuests WHERE id=3";
if ($conn->query($sql) === TRUE) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . $conn->error;
}
 $sql = "UPDATE MyGuests SET
lastname='Doe' WHERE id=2";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn-
>error;
}

More Related Content

What's hot (19)

Karan chanana
Karan chananaKaran chanana
Karan chanana
karan chanana
 
[Php] navigations
[Php] navigations[Php] navigations
[Php] navigations
Vishal Gurujuwada
 
[Php] navigations
[Php] navigations[Php] navigations
[Php] navigations
Thai Pham
 
WordPress: From Antispambot to Zeroize
WordPress: From Antispambot to ZeroizeWordPress: From Antispambot to Zeroize
WordPress: From Antispambot to Zeroize
Yoav Farhi
 
TDC2015 Porto Alegre - Automate everything with Phing !
TDC2015 Porto Alegre - Automate everything with Phing !TDC2015 Porto Alegre - Automate everything with Phing !
TDC2015 Porto Alegre - Automate everything with Phing !
Matheus Marabesi
 
TerminalでTwitter
TerminalでTwitterTerminalでTwitter
TerminalでTwitter
Yoshihiro Sugi
 
Conexion php
Conexion phpConexion php
Conexion php
Luis Reategui Vargas
 
Darkmira Tour PHP 2016 - Automatizando Tarefas com Phing
Darkmira Tour PHP 2016 - Automatizando Tarefas com PhingDarkmira Tour PHP 2016 - Automatizando Tarefas com Phing
Darkmira Tour PHP 2016 - Automatizando Tarefas com Phing
Matheus Marabesi
 
Calculadora
CalculadoraCalculadora
Calculadora
CBTa 120
 
Presentation on php string function part-2
Presentation on php string function part-2Presentation on php string function part-2
Presentation on php string function part-2
Mysoftheaven (BD) Ltd.
 
Node.js - Demnächst auf einem Server in Ihrer Nähe
Node.js - Demnächst auf einem Server in Ihrer NäheNode.js - Demnächst auf einem Server in Ihrer Nähe
Node.js - Demnächst auf einem Server in Ihrer Nähe
Ralph Winzinger
 
5. hello popescu
5. hello popescu5. hello popescu
5. hello popescu
Razvan Raducanu, PhD
 
Growing jQuery
Growing jQueryGrowing jQuery
Growing jQuery
gueste8d8bc
 
Perl Fitxers i Directoris
Perl Fitxers i DirectorisPerl Fitxers i Directoris
Perl Fitxers i Directoris
frankiejol
 
Laravel the right way
Laravel   the right wayLaravel   the right way
Laravel the right way
Matheus Marabesi
 
London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)
Dennis Knochenwefel
 
subversion hacks (create a commit template)
subversion hacks (create a commit template)subversion hacks (create a commit template)
subversion hacks (create a commit template)
Hirohito Kato
 
6. hello popescu 2
6. hello popescu 26. hello popescu 2
6. hello popescu 2
Razvan Raducanu, PhD
 
Threading
ThreadingThreading
Threading
b290572
 
[Php] navigations
[Php] navigations[Php] navigations
[Php] navigations
Thai Pham
 
WordPress: From Antispambot to Zeroize
WordPress: From Antispambot to ZeroizeWordPress: From Antispambot to Zeroize
WordPress: From Antispambot to Zeroize
Yoav Farhi
 
TDC2015 Porto Alegre - Automate everything with Phing !
TDC2015 Porto Alegre - Automate everything with Phing !TDC2015 Porto Alegre - Automate everything with Phing !
TDC2015 Porto Alegre - Automate everything with Phing !
Matheus Marabesi
 
Darkmira Tour PHP 2016 - Automatizando Tarefas com Phing
Darkmira Tour PHP 2016 - Automatizando Tarefas com PhingDarkmira Tour PHP 2016 - Automatizando Tarefas com Phing
Darkmira Tour PHP 2016 - Automatizando Tarefas com Phing
Matheus Marabesi
 
Calculadora
CalculadoraCalculadora
Calculadora
CBTa 120
 
Presentation on php string function part-2
Presentation on php string function part-2Presentation on php string function part-2
Presentation on php string function part-2
Mysoftheaven (BD) Ltd.
 
Node.js - Demnächst auf einem Server in Ihrer Nähe
Node.js - Demnächst auf einem Server in Ihrer NäheNode.js - Demnächst auf einem Server in Ihrer Nähe
Node.js - Demnächst auf einem Server in Ihrer Nähe
Ralph Winzinger
 
Perl Fitxers i Directoris
Perl Fitxers i DirectorisPerl Fitxers i Directoris
Perl Fitxers i Directoris
frankiejol
 
London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)
Dennis Knochenwefel
 
subversion hacks (create a commit template)
subversion hacks (create a commit template)subversion hacks (create a commit template)
subversion hacks (create a commit template)
Hirohito Kato
 
Threading
ThreadingThreading
Threading
b290572
 

Similar to Php (20)

chapter_Seven Database manipulation using php.pptx
chapter_Seven Database manipulation using php.pptxchapter_Seven Database manipulation using php.pptx
chapter_Seven Database manipulation using php.pptx
Getawu
 
My shell
My shellMy shell
My shell
Ahmed Salah
 
Php 101: PDO
Php 101: PDOPhp 101: PDO
Php 101: PDO
Jeremy Kendall
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data Objects
Wez Furlong
 
Basics of Working with PHP and MySQL.pptx
Basics of Working with PHP and MySQL.pptxBasics of Working with PHP and MySQL.pptx
Basics of Working with PHP and MySQL.pptx
jensas21
 
PHP variables
PHP  variablesPHP  variables
PHP variables
Siddique Ibrahim
 
The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistence
Hugo Hamon
 
PHP and Rich Internet Applications
PHP and Rich Internet ApplicationsPHP and Rich Internet Applications
PHP and Rich Internet Applications
elliando dias
 
Php functions
Php functionsPhp functions
Php functions
JIGAR MAKHIJA
 
Smelling your code
Smelling your codeSmelling your code
Smelling your code
Raju Mazumder
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
Rifat Nabi
 
R57shell
R57shellR57shell
R57shell
ady36
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11
Michelangelo van Dam
 
PHP and Rich Internet Applications
PHP and Rich Internet ApplicationsPHP and Rich Internet Applications
PHP and Rich Internet Applications
elliando dias
 
PHP and MySQL
PHP and MySQLPHP and MySQL
PHP and MySQL
Sanketkumar Biswas
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Masahiro Nagano
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
Michelangelo van Dam
 
Symfony2 - extending the console component
Symfony2 - extending the console componentSymfony2 - extending the console component
Symfony2 - extending the console component
Hugo Hamon
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
Kang-min Liu
 
Drush. Secrets come out.
Drush. Secrets come out.Drush. Secrets come out.
Drush. Secrets come out.
Alex S
 
chapter_Seven Database manipulation using php.pptx
chapter_Seven Database manipulation using php.pptxchapter_Seven Database manipulation using php.pptx
chapter_Seven Database manipulation using php.pptx
Getawu
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data Objects
Wez Furlong
 
Basics of Working with PHP and MySQL.pptx
Basics of Working with PHP and MySQL.pptxBasics of Working with PHP and MySQL.pptx
Basics of Working with PHP and MySQL.pptx
jensas21
 
The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistence
Hugo Hamon
 
PHP and Rich Internet Applications
PHP and Rich Internet ApplicationsPHP and Rich Internet Applications
PHP and Rich Internet Applications
elliando dias
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
Rifat Nabi
 
R57shell
R57shellR57shell
R57shell
ady36
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11
Michelangelo van Dam
 
PHP and Rich Internet Applications
PHP and Rich Internet ApplicationsPHP and Rich Internet Applications
PHP and Rich Internet Applications
elliando dias
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Masahiro Nagano
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
Michelangelo van Dam
 
Symfony2 - extending the console component
Symfony2 - extending the console componentSymfony2 - extending the console component
Symfony2 - extending the console component
Hugo Hamon
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
Kang-min Liu
 
Drush. Secrets come out.
Drush. Secrets come out.Drush. Secrets come out.
Drush. Secrets come out.
Alex S
 

Recently uploaded (20)

The Mo You Know Heads to LA for the 2025 BET Experience
The Mo You Know Heads to LA for the 2025 BET ExperienceThe Mo You Know Heads to LA for the 2025 BET Experience
The Mo You Know Heads to LA for the 2025 BET Experience
PRnews2
 
Introduction to Social Media Marketing..
Introduction to Social Media Marketing..Introduction to Social Media Marketing..
Introduction to Social Media Marketing..
ragguru45
 
The Product-Market Fit Staircase (for consumer businesses)
The Product-Market Fit Staircase (for consumer businesses)The Product-Market Fit Staircase (for consumer businesses)
The Product-Market Fit Staircase (for consumer businesses)
ssuser276a18
 
Dmytro Lukianov: «Досвідчений Agile» як етап розвитку проєктного менеджера (U...
Dmytro Lukianov: «Досвідчений Agile» як етап розвитку проєктного менеджера (U...Dmytro Lukianov: «Досвідчений Agile» як етап розвитку проєктного менеджера (U...
Dmytro Lukianov: «Досвідчений Agile» як етап розвитку проєктного менеджера (U...
Lviv Startup Club
 
Viet Nam Inovation and Private Capital Report
Viet Nam Inovation and Private Capital ReportViet Nam Inovation and Private Capital Report
Viet Nam Inovation and Private Capital Report
22jdh6jxdg
 
Oleksandr Osypenko: Вступ до PMP та огляд курсу (UA)
Oleksandr Osypenko: Вступ до PMP та огляд курсу (UA)Oleksandr Osypenko: Вступ до PMP та огляд курсу (UA)
Oleksandr Osypenko: Вступ до PMP та огляд курсу (UA)
Lviv Startup Club
 
Keppel Investor Day 2025 - Presentation Slides - GCAT.pdf
Keppel Investor Day 2025 - Presentation Slides - GCAT.pdfKeppel Investor Day 2025 - Presentation Slides - GCAT.pdf
Keppel Investor Day 2025 - Presentation Slides - GCAT.pdf
KeppelCorporation
 
EEN Decentralized Online Training on AI & Green Innovation at Standort Tirol
EEN Decentralized Online Training on AI & Green Innovation at Standort TirolEEN Decentralized Online Training on AI & Green Innovation at Standort Tirol
EEN Decentralized Online Training on AI & Green Innovation at Standort Tirol
MIPLM
 
Paul Turovsky - Wealth Of Knowledge And Expertise
Paul Turovsky - Wealth Of Knowledge And ExpertisePaul Turovsky - Wealth Of Knowledge And Expertise
Paul Turovsky - Wealth Of Knowledge And Expertise
Paul Turovsky
 
Mykhailo Hryhorash: Архітектура IT-рішень (Частина 1) (UA)
Mykhailo Hryhorash: Архітектура IT-рішень (Частина 1) (UA)Mykhailo Hryhorash: Архітектура IT-рішень (Частина 1) (UA)
Mykhailo Hryhorash: Архітектура IT-рішень (Частина 1) (UA)
Lviv Startup Club
 
The International Traffic in Arms Regulations (ITAR)- 2023 (2).pptx
The International Traffic in Arms Regulations (ITAR)- 2023 (2).pptxThe International Traffic in Arms Regulations (ITAR)- 2023 (2).pptx
The International Traffic in Arms Regulations (ITAR)- 2023 (2).pptx
VishPothapu
 
Market Dynamics Sample Report - Redacted
Market Dynamics Sample Report - RedactedMarket Dynamics Sample Report - Redacted
Market Dynamics Sample Report - Redacted
Mintel Group
 
Powerful FRL Units Range by Airmax Pneumatics
Powerful FRL Units Range by Airmax PneumaticsPowerful FRL Units Range by Airmax Pneumatics
Powerful FRL Units Range by Airmax Pneumatics
Airmax Team
 
Employment Law Spring Update 2025 slides.pdf
Employment Law Spring Update 2025 slides.pdfEmployment Law Spring Update 2025 slides.pdf
Employment Law Spring Update 2025 slides.pdf
FelixPerez547899
 
Growth Marketing Agency: Scalable Strategies for Sustainable Business Growth
Growth Marketing Agency: Scalable Strategies for Sustainable Business GrowthGrowth Marketing Agency: Scalable Strategies for Sustainable Business Growth
Growth Marketing Agency: Scalable Strategies for Sustainable Business Growth
shivamsinghseo7
 
Alyona Lubchak: Вижити у трансформації: чому впровадження процесів зазнає пор...
Alyona Lubchak: Вижити у трансформації: чому впровадження процесів зазнає пор...Alyona Lubchak: Вижити у трансформації: чому впровадження процесів зазнає пор...
Alyona Lubchak: Вижити у трансформації: чому впровадження процесів зазнає пор...
Lviv Startup Club
 
Event Report - SAP Sapphire 2025 Orlando - Good work more to come
Event Report - SAP Sapphire 2025 Orlando - Good work more to comeEvent Report - SAP Sapphire 2025 Orlando - Good work more to come
Event Report - SAP Sapphire 2025 Orlando - Good work more to come
Holger Mueller
 
Nternational banking serice and the future of bankin
Nternational banking serice and the future of bankinNternational banking serice and the future of bankin
Nternational banking serice and the future of bankin
taminhthu2736
 
hospitality-law-complete-notes-201-7.pdf
hospitality-law-complete-notes-201-7.pdfhospitality-law-complete-notes-201-7.pdf
hospitality-law-complete-notes-201-7.pdf
NewtonKibira
 
Prakash Hinduja – Chairman & Managing Director, Jaihind Projects Limited
Prakash Hinduja – Chairman & Managing Director, Jaihind Projects LimitedPrakash Hinduja – Chairman & Managing Director, Jaihind Projects Limited
Prakash Hinduja – Chairman & Managing Director, Jaihind Projects Limited
deepakahujamumbai01
 
The Mo You Know Heads to LA for the 2025 BET Experience
The Mo You Know Heads to LA for the 2025 BET ExperienceThe Mo You Know Heads to LA for the 2025 BET Experience
The Mo You Know Heads to LA for the 2025 BET Experience
PRnews2
 
Introduction to Social Media Marketing..
Introduction to Social Media Marketing..Introduction to Social Media Marketing..
Introduction to Social Media Marketing..
ragguru45
 
The Product-Market Fit Staircase (for consumer businesses)
The Product-Market Fit Staircase (for consumer businesses)The Product-Market Fit Staircase (for consumer businesses)
The Product-Market Fit Staircase (for consumer businesses)
ssuser276a18
 
Dmytro Lukianov: «Досвідчений Agile» як етап розвитку проєктного менеджера (U...
Dmytro Lukianov: «Досвідчений Agile» як етап розвитку проєктного менеджера (U...Dmytro Lukianov: «Досвідчений Agile» як етап розвитку проєктного менеджера (U...
Dmytro Lukianov: «Досвідчений Agile» як етап розвитку проєктного менеджера (U...
Lviv Startup Club
 
Viet Nam Inovation and Private Capital Report
Viet Nam Inovation and Private Capital ReportViet Nam Inovation and Private Capital Report
Viet Nam Inovation and Private Capital Report
22jdh6jxdg
 
Oleksandr Osypenko: Вступ до PMP та огляд курсу (UA)
Oleksandr Osypenko: Вступ до PMP та огляд курсу (UA)Oleksandr Osypenko: Вступ до PMP та огляд курсу (UA)
Oleksandr Osypenko: Вступ до PMP та огляд курсу (UA)
Lviv Startup Club
 
Keppel Investor Day 2025 - Presentation Slides - GCAT.pdf
Keppel Investor Day 2025 - Presentation Slides - GCAT.pdfKeppel Investor Day 2025 - Presentation Slides - GCAT.pdf
Keppel Investor Day 2025 - Presentation Slides - GCAT.pdf
KeppelCorporation
 
EEN Decentralized Online Training on AI & Green Innovation at Standort Tirol
EEN Decentralized Online Training on AI & Green Innovation at Standort TirolEEN Decentralized Online Training on AI & Green Innovation at Standort Tirol
EEN Decentralized Online Training on AI & Green Innovation at Standort Tirol
MIPLM
 
Paul Turovsky - Wealth Of Knowledge And Expertise
Paul Turovsky - Wealth Of Knowledge And ExpertisePaul Turovsky - Wealth Of Knowledge And Expertise
Paul Turovsky - Wealth Of Knowledge And Expertise
Paul Turovsky
 
Mykhailo Hryhorash: Архітектура IT-рішень (Частина 1) (UA)
Mykhailo Hryhorash: Архітектура IT-рішень (Частина 1) (UA)Mykhailo Hryhorash: Архітектура IT-рішень (Частина 1) (UA)
Mykhailo Hryhorash: Архітектура IT-рішень (Частина 1) (UA)
Lviv Startup Club
 
The International Traffic in Arms Regulations (ITAR)- 2023 (2).pptx
The International Traffic in Arms Regulations (ITAR)- 2023 (2).pptxThe International Traffic in Arms Regulations (ITAR)- 2023 (2).pptx
The International Traffic in Arms Regulations (ITAR)- 2023 (2).pptx
VishPothapu
 
Market Dynamics Sample Report - Redacted
Market Dynamics Sample Report - RedactedMarket Dynamics Sample Report - Redacted
Market Dynamics Sample Report - Redacted
Mintel Group
 
Powerful FRL Units Range by Airmax Pneumatics
Powerful FRL Units Range by Airmax PneumaticsPowerful FRL Units Range by Airmax Pneumatics
Powerful FRL Units Range by Airmax Pneumatics
Airmax Team
 
Employment Law Spring Update 2025 slides.pdf
Employment Law Spring Update 2025 slides.pdfEmployment Law Spring Update 2025 slides.pdf
Employment Law Spring Update 2025 slides.pdf
FelixPerez547899
 
Growth Marketing Agency: Scalable Strategies for Sustainable Business Growth
Growth Marketing Agency: Scalable Strategies for Sustainable Business GrowthGrowth Marketing Agency: Scalable Strategies for Sustainable Business Growth
Growth Marketing Agency: Scalable Strategies for Sustainable Business Growth
shivamsinghseo7
 
Alyona Lubchak: Вижити у трансформації: чому впровадження процесів зазнає пор...
Alyona Lubchak: Вижити у трансформації: чому впровадження процесів зазнає пор...Alyona Lubchak: Вижити у трансформації: чому впровадження процесів зазнає пор...
Alyona Lubchak: Вижити у трансформації: чому впровадження процесів зазнає пор...
Lviv Startup Club
 
Event Report - SAP Sapphire 2025 Orlando - Good work more to come
Event Report - SAP Sapphire 2025 Orlando - Good work more to comeEvent Report - SAP Sapphire 2025 Orlando - Good work more to come
Event Report - SAP Sapphire 2025 Orlando - Good work more to come
Holger Mueller
 
Nternational banking serice and the future of bankin
Nternational banking serice and the future of bankinNternational banking serice and the future of bankin
Nternational banking serice and the future of bankin
taminhthu2736
 
hospitality-law-complete-notes-201-7.pdf
hospitality-law-complete-notes-201-7.pdfhospitality-law-complete-notes-201-7.pdf
hospitality-law-complete-notes-201-7.pdf
NewtonKibira
 
Prakash Hinduja – Chairman & Managing Director, Jaihind Projects Limited
Prakash Hinduja – Chairman & Managing Director, Jaihind Projects LimitedPrakash Hinduja – Chairman & Managing Director, Jaihind Projects Limited
Prakash Hinduja – Chairman & Managing Director, Jaihind Projects Limited
deepakahujamumbai01
 

Php

  • 5.  $txt = "Hello world!"; $x = 5; $y = 10.5; echo $txt; Echo $Txt; * Variable name must begin with a letter or a underscore( must not use numeric)
  • 6.  n is replaced by the newline character  t is replaced by the tab character  $ is replaced by the dollar sign itself ($)  " is replaced by a single double-quote (")  is replaced by a single backslash ()
  • 8.  අගය නනොනෙනස්ෙ පෙතී.  <?php  define("MINSIZE", 50);  echo MINSIZE;  echo constant("MINSIZE"); // same thing as the previous line  ?>
  • 9. <?php $cars = array("Volvo", "BMW", "Toyota"); echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . "."; ?>
  • 10. Syntax if (condition) { code to be executed if condition is true; } else { code to be executed if condition is false; }
  • 11. Example <?php $t = 1000; if ($t < 500) { echo “Small one"; } else { echo “Big one"; } ?>
  • 12.  while (condition is true) { code to be executed; }  <?php $x = 1; while($x <= 5) { echo "The number is: $x <br>"; $x++; } ?>
  • 13.  <?php $x = 0; while($x < 10) { if ($x == 4) { break; } echo "The number is: $x <br>"; $x++; } ?>
  • 14.  Login using your root (user)  From the main menu choose Databases  In the create database field type in a name for your database
  • 15.  Click on Users in the main menu.  Choose the Add User option.  In the section Login Information - type in a username, localhost and a password
  • 16.  GLOBAL privileges apply to ALL databases on the server ( leave this section BLANK)  Then click the Add User button  Click Edit Privileges to assign access to a specific database of created user
  • 17.  <?php $servername = "localhost"; $username = "username"; $password = "password"; // Create connection $conn = new mysqli($servername, $username, $password); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully"; ?>
  • 19.  $sql = "INSERT INTO MyGuests (firstname, lastname, email) VALUES ('John', 'Doe', '[email protected]')"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; }
  • 20. $sql = "DELETE FROM MyGuests WHERE id=3"; if ($conn->query($sql) === TRUE) { echo "Record deleted successfully"; } else { echo "Error deleting record: " . $conn->error; }
  • 21.  $sql = "UPDATE MyGuests SET lastname='Doe' WHERE id=2"; if ($conn->query($sql) === TRUE) { echo "Record updated successfully"; } else { echo "Error updating record: " . $conn- >error; }