0% found this document useful (0 votes)
14 views12 pages

HTML Css & PHP

The document provides an overview of variables in PHP, detailing their types, including local and global variables. It also explains PHP data types, categorizing them into scalar, compound, and special types, with specific examples of scalar types such as Boolean, Integer, Float, and Strings. Additionally, it describes compound data types, focusing on arrays and their ability to store multiple values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views12 pages

HTML Css & PHP

The document provides an overview of variables in PHP, detailing their types, including local and global variables. It also explains PHP data types, categorizing them into scalar, compound, and special types, with specific examples of scalar types such as Boolean, Integer, Float, and Strings. Additionally, it describes compound data types, focusing on arrays and their ability to store multiple values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Web Development

HTML CSS & PHP


Content

 Variables
 Types of Variables
 Data types
Variables

A variable in php is a name of memory


location that holds data. A variable is a
temporary storage that is used to store data
temporarily.
 In php a variable is declared using $ sign
followed by a variable name.
Types of Variables

 There are so many types of variables but some


are given below.

1. Local Variable
2. Global Variable
Local Variable

 The variable declared within a function are


called local variables to that function. These
local variables have their scope only in that
particular function in which they are declared.
 This means that these variables cannot be
accessed outside the function, as they have
local scope.
Global Variables

 The variables declared outside a function are


called global variables. These variables can be
accessed directly outside a function. To access
the global variable within a function, use the
global keyword before the variable, however
these variables can be directly accessed or used
outside the function without any keyword.
Therefore there is no need to use any keyword to
access a global variables outside the functions.
Data Types

 Php data types are used to hold different types


of data or value. Php supports 8
 primitive data types that can be further
divided int0 3 categories.

1. Scalar type
2. Compound type
3. Special type
Scalar Types

 There are 4 types of scalar data types in php.

1. Boolean
2. Integer
3. Float
4. strings
Define Scalar Data Types

 Boolean :- this is one of the scalar data types


in php. A Boolean data can be either true or
false. These are predefined constant in php.

 Integer :- this is also part of scalar data types


in php. An integer data type is a non-decimal
number. Rules of integer: an integer must have
at least one digit and must have not a decimal
point.
Define Scalar Data Types

 Float :- a float is a number with a decimal


points or a number exponential form.

 String:- Strings are sequence of characters,


where every character is same as a byte. A
string can hold letters, numbers, and special
character and it can be as large as up to 2gb.
The simplest way to specify a string is to
enclose it in single or double quotes.
Compound Data Types

 There are 2 compound data types in php.

1. Array
2. object
Compound Data Types

 Array :-the array is the collection of


heterogeneous data types. We can store any type
of values in array. Normal variable can store
single value, array can store the multiple values.
 Syntax of Array
<?php
$arr = array(20,’Dit’,5.6);
Print_r($arr);
?>

You might also like