SlideShare a Scribd company logo
PHP BASICS
 DataType
 Variable
 Constant
 Operators
 Control and Looping structure
 Arrays
 PHP Errors
 Include vs Require
By
www.Creativedev.in
DATATYPE
A Data type refer to the type of data a variable can store. A Data type is
determined at runtime by PHP. If you assign a string to a variable, it
becomes a string variable and if you assign an integer value, the variable
becomes an integer variable.
CONTINUE...
PHP supports eight primitive types:
Four scalar types:
1. Boolean
2. integer
3. float (floating-point number, aka double)
4. string
Two compound types:
5. array
6. object
And finally three special types:
7. resource
8. NULL
9. callable
CONTINUE...
Integer : used to specify numeric value
SYNTAX:
<?php $variable = 10; ?>
Float : used to specify real numbers
SYNTAX:
<?php
$variable = -10;
$variable1 = -10.5;
?>
Boolean: values true or false, also 0 or empty.
SYNTAX:
<?php $variable = true; ?>
CONTINUE...
String: sequence of characters included in a single or double quote.
SYNTAX:
<?php
$string = 'Hello World';
$string1 = "Hellon World";
?>
VARIABLE
 Variables are used for storing a values, like text strings, numbers or
arrays.
 All variables in PHP start with a $ symbol.
SYNTAX:
$var_name = value;
Example:
$name = 'Bhumi';
VARIABLE SCOPE
Scope can be defined as the range of availability a variable has to the
program in which it is declared. PHP variables can be one of four scope
types:
1) Local variables
2) Function parameters
3) Global variables
4) Static variables
VARIABLE NAMING RULES
1) A variable name must start with a letter or an underscore "_". Ex,
$1var_name is not valid.
2) Variable names are case sensitive; this means $var_name is different
from $VAR_NAME.
3) A variable name should not contain spaces. If a variable name is more
than one word, it should be separated with underscore. Ex, $var
name is not valid,use $var_name
VARIABLE VARIABLES
Variable variables allow you to access the contents of a variable without
knowing its name directly - it is like indirectly referring to a variable
EXAMPLE:
$a = 'hello';
$$a = 'world';
echo "$a $hello";
VARIABLE TYPE CASTING
Type casting is converting a variable or value into a desired data type.
This is very useful when performing arithmetic computations that require
variables to be of the same data type. Type casting in PHP is done by the
interpreter.
PHP also allows you to cast the data type. This is known as Explicit
casting. The code below demonstrates explicit type casting.
VARIABLE TYPE CASTING EXAMPLE
<?php
$a = 1;
$b = 1.5;
$c = $a + $b;
$c = $a + (int) $b;
echo $c;
?>
CONSTANTS
 A constant is an identifier (name) for an unchangable value.
 A valid constant name starts with a letter or underscore (no $ sign before
the constant name).
Note: Unlike variables, constants are automatically global across the entire
application.Constants are usually In UPPERCASE.
SYNTAX:
define(name, value, case-insensitive)
Parameters:
name: Specifies the name of the constant
value: Specifies the value of the constant
case-insensitive: Specifies whether the constant name should be case-insensitive.
Default is false
CONSTANT EXAMPLES
<?php
define('NAME','Bhumi');
echo NAME;
?>
PHP OPERATORS
1. Arithmetic Operators
OPERATOR DESCRIPTION EXAMPLE RESULT
+ Addition x=2,x+2 4
- Subtraction x=2,5-x 3
* Multiplication x=4,x*5 20
/ Division 15/5,5/2 3
2.5
% Modulus(division
remainder)
5%2,10%8 1
2
++ Increment x=5,x++ 6
-- Decrement x=5,x-- 4
PHP OPERATORS
2. Assignment Operators
OPERATOR EXAMPLE IS THE SAME AS
= x=y x=y
+= x+=y x=x+y
-= x-=y x=x-y
*= x*=y x=x*y
/= x/=y x=x/y
.= x.=y x=x.y
%= X%=y x=x%y
PHP OPERATORS...
3. Logical Operators
OPERATOR DESCRIPTION EXAMPLE
&& and x=6,y=3
(x < 10 && y > 1)
return true
|| OR x=6,y=3
(x==5 || y==5)
return false
! not x=6,y=3
!(x==y)
return true
PHP OPERATORS
4. Comparison Operators
OPERATOR DESCRIPTION EXAMPLE
== is equal to 5==8 return false
!= is not equal 5!=8 return true
<> is not equal 5<>8 return true
> is greater than 5>8 return false
< is less than 5<8 return true
>= is greater than or equal
to
5>=8 return false
<= is less than or equal to 5<=8 return true
CONTINUE...
5. Ternary Operator
? is represent the ternary operator
SYNTAX:
(expr) ? if_expr_true : if_expr_false;
expression evaluates TRUE or FALSE
TRUE: first result (before colon)
FALSE: second one (after colon)
CONTINUE
Ternary Operator Example
<?php
$a = 10;
$b = 13;
echo $a < $b ? 'Yes' : 'No';
?>
CONTROL AND LOOPING STRUCTURE
1. If/else
2. Switch
3. While
4. For loop
5. Foreach
IF/ELSE STATEMENT
Here is the example to use if/else statement
<?php
// change message depending on whether
// number is less than zero or not
$number = -88;
if ($number < 0) {
echo 'That number is negative';
} else {
echo 'That number is either positive or zero';
}
?>
THE IF-ELSEIF-ELSE STATEMENT
<?php
// handle multiple possibilities
if($answer == ‘y’) {
print "The answer was yesn";
else if ($answer == ‘n’) {
print "The answer was non";
}else{
print "Error: $answer is not a valid answern";
}
?>
THE SWITCH-CASE STATEMENT
<?php
// handle multiple possibilities
switch ($answer) {
case 'y':
print "The answer was yesn";
break;
case 'n':
print "The answer was non";
break;
default:
print "Error: $answer is not a valid answern";
break;
}
?>
WHILE LOOP
SYNTAX
while (condition):
code to be executed;
endwhile;
EXAMPLE
<?php
// repeats until counter becomes 10
$counter = 1;
while($counter < 10){
echo $counter;
$counter++;
}
?>
THE DO-WHILE LOOP
SYNTAX:
do {
code to be executed;
} while (condition);
EXAMPLE
<?php
// repeats until counter becomes 10
$counter = 1;
do{
echo $counter;
$counter++;
}while($counter < 10);
?>
THE FOR LOOP
SYNTAX
for (init; cond; incr)
{
code to be executed;
}
init: Is mostly used to set a counter, but can be any code to be executed
once at the beginning of the loop statement.
cond: Is evaluated at beginning of each loop iteration. If the condition
evaluates to TRUE, the loop continues and the code executes. If it
evaluates to FALSE, the execution of the loop ends.
incr: Is mostly used to increment a counter, but can be any code to be
executed at the end of each loop.
BREAKING A LOOP
Occasionally it is necessary to exit from a loop before it has met whatever
completion criteria were specified. To achieve this, the break statement
must be used. The following example contains a loop that uses the break
statement to exit from the loop when i = 100, even though the loop is
designed to iterate 100 times:
for ($i = 0; $i < 100; $i++)
{
if ($i == 10)
{
break;
}
}
CONTINUE
Skipping Statements in Current Loop Iteration.
continue is used within looping structures to skip the rest of the current
loop iteration and continue execution at the condition evaluation and
then the beginning of the next iteration.
for ($i = 0; $i < 5; ++$i) {
if ($i == 2)
continue
print "$in";
}
EXAMPLE:
<?php
// repeat continuously until counter becomes 10
// output:
for ($x=1; $x<10; $x++) {
echo "$x ";
}
?>
ARRAY IN PHP
An array can store one or more values in a single variable
name.
There are three different kind of arrays:
1. Numeric array - An array with a numeric ID key
2. Associative array - An array where each ID key is associated with a
value
3. Multidimensional array - An array containing one or more arrays
FOREACH LOOP
SYNTAX:
foreach (array as value)
{
code to be executed;
}
<?php
$fruits = array(
'a' => 'apple',
'b' => 'banana',
'p' => 'pineapple',
'g' => 'grape');
?>
FOREACH LOOP
$array = ['apple', 'banana', 'orange‘];
foreach ($array as $value) {
$array = strtoupper($value);
}
foreach ($array as $key => $value) {
$array[$key] = strtolower($value);
}
var_dump($array);
array(3) {
[0]=> string(3) "APPLE"
[1]=> string(3) "BANANA"
[2]=> &string(3) "ORANGE"
}
ERRORS AND ERROR MANAGEMENT
Errors:
Basically errors can be of one of two types
External Errors
Logic Errors (Bugs)
What about these error types?
External Errors will always occur at some point or another
External Errors which are not accounted for are Logic Errors
Logic Errors are harder to track down
PHP ERRORS
Four levels of error condition to start with
• Strict standard problems (E_STRICT)
• Notices (E_NOTICE)
• Warnings (E_WARNING)
• Errors (E_ERROR)
To enable error in PHP :
ini_set('display_errors', 1);
error_reporting(E_ALL);
PHP ERRORS EXAMPLE
// E_NOTICE :
<?php echo $x = $y + 3; ?>
Notice: Undefined variable: y
// E_WARNING
<?php $fp = fopen('test_file', 'r'); ?>
Warning: fopen(test_file): failed to open stream: No such file or directory
// E_ERROR
<?php NonFunction(); ?>
Fatal error: Call to undefined function NonFunction()
REQUIRE, INCLUDE
1. require('filename.php');

Include and evaluate the specified file

Fatal Error
2. include('filename.php');

Include and evaluate the specified file

Warning
3. require_once/include_once

If already included,won't be include again
TUTORIAL
1. Write a PHP script using a ‘do while’ loop that accept value from two
input box and perform addition, subtraction, multiplication,
division,modulus, square-root, square, Factorial operation on two value
then display total as the output.
Example:
First value input field + select box for operator selection + second value =
OUTPUT
2.Create a php function that accepts an integer value and other
information like name and outputs a message based on the number
entered by user in input field. Use a ‘switch’ statement for interger and
display values.
For a remainder of 0, print: “Welcome ”, [name],
For a remainder of 1, print: “How are you,[name]?”
For a remainder of 2, print: “I’m doing well, Thank you”
For a remainder of 3, print: “Have a nice day”
For a remainder of 4, print: “Good-bye”
3. Write a PHP program that display series of numbers (1,2,3,4, 5....etc)
in an infinite loop. The program should quit if someone hits a specific
ESCAPE key.
4. Create a PHP Program that Use an associative array to assign for
person name with their favourite color and print “x favourite color is y”
using foreach loop in HTML table
5. Create a PHP program that get system date and convert it in different
formats with usingdisplay in Indian Timezone.
1. 29-Jun-2015
2. 06 29 2013 23:05 PM
3. 29th June 2015 4:20:01
4. Tomorrow
5. Get the date of Next week from today
6. Get the date of Next monday
6.Create a Program which accept Year from selectbox and display
computed age based on the Selected Value.
Ad

More Related Content

What's hot (20)

PHP - Introduction to File Handling with PHP
PHP -  Introduction to  File Handling with PHPPHP -  Introduction to  File Handling with PHP
PHP - Introduction to File Handling with PHP
Vibrant Technologies & Computers
 
Operators php
Operators phpOperators php
Operators php
Chandni Pm
 
PHP variables
PHP  variablesPHP  variables
PHP variables
Siddique Ibrahim
 
Form Handling using PHP
Form Handling using PHPForm Handling using PHP
Form Handling using PHP
Nisa Soomro
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
shanmukhareddy dasi
 
Data types in php
Data types in phpData types in php
Data types in php
ilakkiya
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
Gil Fink
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
WebStackAcademy
 
cascading style sheet ppt
cascading style sheet pptcascading style sheet ppt
cascading style sheet ppt
abhilashagupta
 
Lesson 2 php data types
Lesson 2   php data typesLesson 2   php data types
Lesson 2 php data types
MLG College of Learning, Inc
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
Karmatechnologies Pvt. Ltd.
 
Php string function
Php string function Php string function
Php string function
Ravi Bhadauria
 
Arrays in PHP
Arrays in PHPArrays in PHP
Arrays in PHP
Compare Infobase Limited
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
Zeeshan Ahmed
 
javascript objects
javascript objectsjavascript objects
javascript objects
Vijay Kalyan
 
Php
PhpPhp
Php
Shyam Khant
 
Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1
Gheyath M. Othman
 
php
phpphp
php
ajeetjhajharia
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
 
Javascript validating form
Javascript validating formJavascript validating form
Javascript validating form
Jesus Obenita Jr.
 

Viewers also liked (14)

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
 
What Is Php
What Is PhpWhat Is Php
What Is Php
AVC
 
Ruby Egison
Ruby EgisonRuby Egison
Ruby Egison
Rakuten Group, Inc.
 
Canvas in html5
Canvas in html5Canvas in html5
Canvas in html5
TheCreativedev Blog
 
Network Security Through FIREWALL
Network Security Through FIREWALLNetwork Security Through FIREWALL
Network Security Through FIREWALL
TheCreativedev Blog
 
Introduction to PHP Basics
Introduction to PHP BasicsIntroduction to PHP Basics
Introduction to PHP Basics
TheCreativedev Blog
 
Php
PhpPhp
Php
Ajaigururaj R
 
Ruby Programming Language - Introduction
Ruby Programming Language - IntroductionRuby Programming Language - Introduction
Ruby Programming Language - Introduction
Kwangshin Oh
 
Looping statement
Looping statementLooping statement
Looping statement
ilakkiya
 
Chapter 05 looping
Chapter 05   loopingChapter 05   looping
Chapter 05 looping
Dhani Ahmad
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
MeoRamos
 
Ruby Basics
Ruby BasicsRuby Basics
Ruby Basics
SHC
 
Introduction To PHP
Introduction To PHPIntroduction To PHP
Introduction To PHP
Shweta A
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
Manish Bothra
 
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
 
What Is Php
What Is PhpWhat Is Php
What Is Php
AVC
 
Network Security Through FIREWALL
Network Security Through FIREWALLNetwork Security Through FIREWALL
Network Security Through FIREWALL
TheCreativedev Blog
 
Ruby Programming Language - Introduction
Ruby Programming Language - IntroductionRuby Programming Language - Introduction
Ruby Programming Language - Introduction
Kwangshin Oh
 
Looping statement
Looping statementLooping statement
Looping statement
ilakkiya
 
Chapter 05 looping
Chapter 05   loopingChapter 05   looping
Chapter 05 looping
Dhani Ahmad
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
MeoRamos
 
Ruby Basics
Ruby BasicsRuby Basics
Ruby Basics
SHC
 
Introduction To PHP
Introduction To PHPIntroduction To PHP
Introduction To PHP
Shweta A
 
Ad

Similar to PHP - DataType,Variable,Constant,Operators,Array,Include and require (20)

unit 1.pptx
unit 1.pptxunit 1.pptx
unit 1.pptx
adityathote3
 
Php using variables-operators
Php using variables-operatorsPhp using variables-operators
Php using variables-operators
Khem Puthea
 
How to run PHP code in XAMPP.docx (1).pdf
How to run PHP code in XAMPP.docx (1).pdfHow to run PHP code in XAMPP.docx (1).pdf
How to run PHP code in XAMPP.docx (1).pdf
rajeswaria21
 
OpenGurukul : Language : PHP
OpenGurukul : Language : PHPOpenGurukul : Language : PHP
OpenGurukul : Language : PHP
Open Gurukul
 
Learn PHP Basics
Learn PHP Basics Learn PHP Basics
Learn PHP Basics
McSoftsis
 
Web Technology_10.ppt
Web Technology_10.pptWeb Technology_10.ppt
Web Technology_10.ppt
Aftabali702240
 
FYBSC IT Web Programming Unit IV PHP and MySQL
FYBSC IT Web Programming Unit IV  PHP and MySQLFYBSC IT Web Programming Unit IV  PHP and MySQL
FYBSC IT Web Programming Unit IV PHP and MySQL
Arti Parab Academics
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
prabhatjon
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
Ian Macali
 
PHP PPT FILE
PHP PPT FILEPHP PPT FILE
PHP PPT FILE
AbhishekSharma2958
 
03phpbldgblock
03phpbldgblock03phpbldgblock
03phpbldgblock
IIUM
 
Php introduction
Php introductionPhp introduction
Php introduction
Pratik Patel
 
Php Chapter 1 Training
Php Chapter 1 TrainingPhp Chapter 1 Training
Php Chapter 1 Training
Chris Chubb
 
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP nPHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
ArtiRaju1
 
Introduction To Php For Wit2009
Introduction To Php For Wit2009Introduction To Php For Wit2009
Introduction To Php For Wit2009
cwarren
 
Introduction to php basics
Introduction to php   basicsIntroduction to php   basics
Introduction to php basics
baabtra.com - No. 1 supplier of quality freshers
 
Web 8 | Introduction to PHP
Web 8 | Introduction to PHPWeb 8 | Introduction to PHP
Web 8 | Introduction to PHP
Mohammad Imam Hossain
 
Expressions and Operators.pptx
Expressions and Operators.pptxExpressions and Operators.pptx
Expressions and Operators.pptx
Japneet9
 
PHP Basic
PHP BasicPHP Basic
PHP Basic
Yoeung Vibol
 
Php essentials
Php essentialsPhp essentials
Php essentials
sagaroceanic11
 
Php using variables-operators
Php using variables-operatorsPhp using variables-operators
Php using variables-operators
Khem Puthea
 
How to run PHP code in XAMPP.docx (1).pdf
How to run PHP code in XAMPP.docx (1).pdfHow to run PHP code in XAMPP.docx (1).pdf
How to run PHP code in XAMPP.docx (1).pdf
rajeswaria21
 
OpenGurukul : Language : PHP
OpenGurukul : Language : PHPOpenGurukul : Language : PHP
OpenGurukul : Language : PHP
Open Gurukul
 
Learn PHP Basics
Learn PHP Basics Learn PHP Basics
Learn PHP Basics
McSoftsis
 
FYBSC IT Web Programming Unit IV PHP and MySQL
FYBSC IT Web Programming Unit IV  PHP and MySQLFYBSC IT Web Programming Unit IV  PHP and MySQL
FYBSC IT Web Programming Unit IV PHP and MySQL
Arti Parab Academics
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
prabhatjon
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
Ian Macali
 
03phpbldgblock
03phpbldgblock03phpbldgblock
03phpbldgblock
IIUM
 
Php Chapter 1 Training
Php Chapter 1 TrainingPhp Chapter 1 Training
Php Chapter 1 Training
Chris Chubb
 
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP nPHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
ArtiRaju1
 
Introduction To Php For Wit2009
Introduction To Php For Wit2009Introduction To Php For Wit2009
Introduction To Php For Wit2009
cwarren
 
Expressions and Operators.pptx
Expressions and Operators.pptxExpressions and Operators.pptx
Expressions and Operators.pptx
Japneet9
 
Ad

More from TheCreativedev Blog (6)

Node.js Express Framework
Node.js Express FrameworkNode.js Express Framework
Node.js Express Framework
TheCreativedev Blog
 
Node js Modules and Event Emitters
Node js Modules and Event EmittersNode js Modules and Event Emitters
Node js Modules and Event Emitters
TheCreativedev Blog
 
Node.js Basics
Node.js Basics Node.js Basics
Node.js Basics
TheCreativedev Blog
 
Post via e mail in word press
Post via e mail in word pressPost via e mail in word press
Post via e mail in word press
TheCreativedev Blog
 
Post via e mail in WordPress
Post via e mail in WordPressPost via e mail in WordPress
Post via e mail in WordPress
TheCreativedev Blog
 
TO ADD NEW URL REWRITE RULE IN WORDPRESS
TO ADD NEW URL REWRITE RULE IN WORDPRESSTO ADD NEW URL REWRITE RULE IN WORDPRESS
TO ADD NEW URL REWRITE RULE IN WORDPRESS
TheCreativedev Blog
 

Recently uploaded (20)

Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and MLGyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
Gyrus AI
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
Financial Services Technology Summit 2025
Financial Services Technology Summit 2025Financial Services Technology Summit 2025
Financial Services Technology Summit 2025
Ray Bugg
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
The Future of Cisco Cloud Security: Innovations and AI Integration
The Future of Cisco Cloud Security: Innovations and AI IntegrationThe Future of Cisco Cloud Security: Innovations and AI Integration
The Future of Cisco Cloud Security: Innovations and AI Integration
Re-solution Data Ltd
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
AI You Can Trust: The Critical Role of Governance and Quality.pdf
AI You Can Trust: The Critical Role of Governance and Quality.pdfAI You Can Trust: The Critical Role of Governance and Quality.pdf
AI You Can Trust: The Critical Role of Governance and Quality.pdf
Precisely
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Does Pornify Allow NSFW? Everything You Should Know
Does Pornify Allow NSFW? Everything You Should KnowDoes Pornify Allow NSFW? Everything You Should Know
Does Pornify Allow NSFW? Everything You Should Know
Pornify CC
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and MLGyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
Gyrus AI
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
Financial Services Technology Summit 2025
Financial Services Technology Summit 2025Financial Services Technology Summit 2025
Financial Services Technology Summit 2025
Ray Bugg
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
The Future of Cisco Cloud Security: Innovations and AI Integration
The Future of Cisco Cloud Security: Innovations and AI IntegrationThe Future of Cisco Cloud Security: Innovations and AI Integration
The Future of Cisco Cloud Security: Innovations and AI Integration
Re-solution Data Ltd
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
AI You Can Trust: The Critical Role of Governance and Quality.pdf
AI You Can Trust: The Critical Role of Governance and Quality.pdfAI You Can Trust: The Critical Role of Governance and Quality.pdf
AI You Can Trust: The Critical Role of Governance and Quality.pdf
Precisely
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Does Pornify Allow NSFW? Everything You Should Know
Does Pornify Allow NSFW? Everything You Should KnowDoes Pornify Allow NSFW? Everything You Should Know
Does Pornify Allow NSFW? Everything You Should Know
Pornify CC
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 

PHP - DataType,Variable,Constant,Operators,Array,Include and require

  • 1. PHP BASICS  DataType  Variable  Constant  Operators  Control and Looping structure  Arrays  PHP Errors  Include vs Require By www.Creativedev.in
  • 2. DATATYPE A Data type refer to the type of data a variable can store. A Data type is determined at runtime by PHP. If you assign a string to a variable, it becomes a string variable and if you assign an integer value, the variable becomes an integer variable.
  • 3. CONTINUE... PHP supports eight primitive types: Four scalar types: 1. Boolean 2. integer 3. float (floating-point number, aka double) 4. string Two compound types: 5. array 6. object And finally three special types: 7. resource 8. NULL 9. callable
  • 4. CONTINUE... Integer : used to specify numeric value SYNTAX: <?php $variable = 10; ?> Float : used to specify real numbers SYNTAX: <?php $variable = -10; $variable1 = -10.5; ?> Boolean: values true or false, also 0 or empty. SYNTAX: <?php $variable = true; ?>
  • 5. CONTINUE... String: sequence of characters included in a single or double quote. SYNTAX: <?php $string = 'Hello World'; $string1 = "Hellon World"; ?>
  • 6. VARIABLE  Variables are used for storing a values, like text strings, numbers or arrays.  All variables in PHP start with a $ symbol. SYNTAX: $var_name = value; Example: $name = 'Bhumi';
  • 7. VARIABLE SCOPE Scope can be defined as the range of availability a variable has to the program in which it is declared. PHP variables can be one of four scope types: 1) Local variables 2) Function parameters 3) Global variables 4) Static variables
  • 8. VARIABLE NAMING RULES 1) A variable name must start with a letter or an underscore "_". Ex, $1var_name is not valid. 2) Variable names are case sensitive; this means $var_name is different from $VAR_NAME. 3) A variable name should not contain spaces. If a variable name is more than one word, it should be separated with underscore. Ex, $var name is not valid,use $var_name
  • 9. VARIABLE VARIABLES Variable variables allow you to access the contents of a variable without knowing its name directly - it is like indirectly referring to a variable EXAMPLE: $a = 'hello'; $$a = 'world'; echo "$a $hello";
  • 10. VARIABLE TYPE CASTING Type casting is converting a variable or value into a desired data type. This is very useful when performing arithmetic computations that require variables to be of the same data type. Type casting in PHP is done by the interpreter. PHP also allows you to cast the data type. This is known as Explicit casting. The code below demonstrates explicit type casting.
  • 11. VARIABLE TYPE CASTING EXAMPLE <?php $a = 1; $b = 1.5; $c = $a + $b; $c = $a + (int) $b; echo $c; ?>
  • 12. CONSTANTS  A constant is an identifier (name) for an unchangable value.  A valid constant name starts with a letter or underscore (no $ sign before the constant name). Note: Unlike variables, constants are automatically global across the entire application.Constants are usually In UPPERCASE. SYNTAX: define(name, value, case-insensitive) Parameters: name: Specifies the name of the constant value: Specifies the value of the constant case-insensitive: Specifies whether the constant name should be case-insensitive. Default is false
  • 14. PHP OPERATORS 1. Arithmetic Operators OPERATOR DESCRIPTION EXAMPLE RESULT + Addition x=2,x+2 4 - Subtraction x=2,5-x 3 * Multiplication x=4,x*5 20 / Division 15/5,5/2 3 2.5 % Modulus(division remainder) 5%2,10%8 1 2 ++ Increment x=5,x++ 6 -- Decrement x=5,x-- 4
  • 15. PHP OPERATORS 2. Assignment Operators OPERATOR EXAMPLE IS THE SAME AS = x=y x=y += x+=y x=x+y -= x-=y x=x-y *= x*=y x=x*y /= x/=y x=x/y .= x.=y x=x.y %= X%=y x=x%y
  • 16. PHP OPERATORS... 3. Logical Operators OPERATOR DESCRIPTION EXAMPLE && and x=6,y=3 (x < 10 && y > 1) return true || OR x=6,y=3 (x==5 || y==5) return false ! not x=6,y=3 !(x==y) return true
  • 17. PHP OPERATORS 4. Comparison Operators OPERATOR DESCRIPTION EXAMPLE == is equal to 5==8 return false != is not equal 5!=8 return true <> is not equal 5<>8 return true > is greater than 5>8 return false < is less than 5<8 return true >= is greater than or equal to 5>=8 return false <= is less than or equal to 5<=8 return true
  • 18. CONTINUE... 5. Ternary Operator ? is represent the ternary operator SYNTAX: (expr) ? if_expr_true : if_expr_false; expression evaluates TRUE or FALSE TRUE: first result (before colon) FALSE: second one (after colon)
  • 19. CONTINUE Ternary Operator Example <?php $a = 10; $b = 13; echo $a < $b ? 'Yes' : 'No'; ?>
  • 20. CONTROL AND LOOPING STRUCTURE 1. If/else 2. Switch 3. While 4. For loop 5. Foreach
  • 21. IF/ELSE STATEMENT Here is the example to use if/else statement <?php // change message depending on whether // number is less than zero or not $number = -88; if ($number < 0) { echo 'That number is negative'; } else { echo 'That number is either positive or zero'; } ?>
  • 22. THE IF-ELSEIF-ELSE STATEMENT <?php // handle multiple possibilities if($answer == ‘y’) { print "The answer was yesn"; else if ($answer == ‘n’) { print "The answer was non"; }else{ print "Error: $answer is not a valid answern"; } ?>
  • 23. THE SWITCH-CASE STATEMENT <?php // handle multiple possibilities switch ($answer) { case 'y': print "The answer was yesn"; break; case 'n': print "The answer was non"; break; default: print "Error: $answer is not a valid answern"; break; } ?>
  • 24. WHILE LOOP SYNTAX while (condition): code to be executed; endwhile; EXAMPLE <?php // repeats until counter becomes 10 $counter = 1; while($counter < 10){ echo $counter; $counter++; } ?>
  • 25. THE DO-WHILE LOOP SYNTAX: do { code to be executed; } while (condition); EXAMPLE <?php // repeats until counter becomes 10 $counter = 1; do{ echo $counter; $counter++; }while($counter < 10); ?>
  • 26. THE FOR LOOP SYNTAX for (init; cond; incr) { code to be executed; } init: Is mostly used to set a counter, but can be any code to be executed once at the beginning of the loop statement. cond: Is evaluated at beginning of each loop iteration. If the condition evaluates to TRUE, the loop continues and the code executes. If it evaluates to FALSE, the execution of the loop ends. incr: Is mostly used to increment a counter, but can be any code to be executed at the end of each loop.
  • 27. BREAKING A LOOP Occasionally it is necessary to exit from a loop before it has met whatever completion criteria were specified. To achieve this, the break statement must be used. The following example contains a loop that uses the break statement to exit from the loop when i = 100, even though the loop is designed to iterate 100 times: for ($i = 0; $i < 100; $i++) { if ($i == 10) { break; } }
  • 28. CONTINUE Skipping Statements in Current Loop Iteration. continue is used within looping structures to skip the rest of the current loop iteration and continue execution at the condition evaluation and then the beginning of the next iteration. for ($i = 0; $i < 5; ++$i) { if ($i == 2) continue print "$in"; }
  • 29. EXAMPLE: <?php // repeat continuously until counter becomes 10 // output: for ($x=1; $x<10; $x++) { echo "$x "; } ?>
  • 30. ARRAY IN PHP An array can store one or more values in a single variable name. There are three different kind of arrays: 1. Numeric array - An array with a numeric ID key 2. Associative array - An array where each ID key is associated with a value 3. Multidimensional array - An array containing one or more arrays
  • 31. FOREACH LOOP SYNTAX: foreach (array as value) { code to be executed; } <?php $fruits = array( 'a' => 'apple', 'b' => 'banana', 'p' => 'pineapple', 'g' => 'grape'); ?>
  • 32. FOREACH LOOP $array = ['apple', 'banana', 'orange‘]; foreach ($array as $value) { $array = strtoupper($value); } foreach ($array as $key => $value) { $array[$key] = strtolower($value); } var_dump($array); array(3) { [0]=> string(3) "APPLE" [1]=> string(3) "BANANA" [2]=> &string(3) "ORANGE" }
  • 33. ERRORS AND ERROR MANAGEMENT Errors: Basically errors can be of one of two types External Errors Logic Errors (Bugs) What about these error types? External Errors will always occur at some point or another External Errors which are not accounted for are Logic Errors Logic Errors are harder to track down
  • 34. PHP ERRORS Four levels of error condition to start with • Strict standard problems (E_STRICT) • Notices (E_NOTICE) • Warnings (E_WARNING) • Errors (E_ERROR) To enable error in PHP : ini_set('display_errors', 1); error_reporting(E_ALL);
  • 35. PHP ERRORS EXAMPLE // E_NOTICE : <?php echo $x = $y + 3; ?> Notice: Undefined variable: y // E_WARNING <?php $fp = fopen('test_file', 'r'); ?> Warning: fopen(test_file): failed to open stream: No such file or directory // E_ERROR <?php NonFunction(); ?> Fatal error: Call to undefined function NonFunction()
  • 36. REQUIRE, INCLUDE 1. require('filename.php');  Include and evaluate the specified file  Fatal Error 2. include('filename.php');  Include and evaluate the specified file  Warning 3. require_once/include_once  If already included,won't be include again
  • 37. TUTORIAL 1. Write a PHP script using a ‘do while’ loop that accept value from two input box and perform addition, subtraction, multiplication, division,modulus, square-root, square, Factorial operation on two value then display total as the output. Example: First value input field + select box for operator selection + second value = OUTPUT
  • 38. 2.Create a php function that accepts an integer value and other information like name and outputs a message based on the number entered by user in input field. Use a ‘switch’ statement for interger and display values. For a remainder of 0, print: “Welcome ”, [name], For a remainder of 1, print: “How are you,[name]?” For a remainder of 2, print: “I’m doing well, Thank you” For a remainder of 3, print: “Have a nice day” For a remainder of 4, print: “Good-bye”
  • 39. 3. Write a PHP program that display series of numbers (1,2,3,4, 5....etc) in an infinite loop. The program should quit if someone hits a specific ESCAPE key. 4. Create a PHP Program that Use an associative array to assign for person name with their favourite color and print “x favourite color is y” using foreach loop in HTML table
  • 40. 5. Create a PHP program that get system date and convert it in different formats with usingdisplay in Indian Timezone. 1. 29-Jun-2015 2. 06 29 2013 23:05 PM 3. 29th June 2015 4:20:01 4. Tomorrow 5. Get the date of Next week from today 6. Get the date of Next monday 6.Create a Program which accept Year from selectbox and display computed age based on the Selected Value.
  翻译: