Before starting use of PHP for developing websites its necessary that you should know about the basics of language. So, here we are trying to explain basics related to PHP programming.
1. Variable
A variable is basic element of a programming language. Variable is a main way to store information within a PHP program. The important things about variables in PHP is explained as following:
>> Variables are denoted with a leading dollar sign i.e $a. Unlike other scripting languages like Java, C etc. no data type keyword is used along to define variable.
>> Variables are automatic parsing type in PHP i.e. they convert from one data type another whenever its needed. There, is no need to parse variables explicitly.
>> PHP has a total of eight data types which we use to construct our variables:
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).
The first five are simple types, and the next two (arrays and objects) are compound - the compound types can package up other arbitrary values of arbitrary type, whereas the simple types cannot.
Example declaration of a variable:
$a = 10; // Integer type Variable
$b = 34.5; // Float type Variable
$c = 'Hello World!'; // String type Variable
1. Variable
A variable is basic element of a programming language. Variable is a main way to store information within a PHP program. The important things about variables in PHP is explained as following:
>> Variables are denoted with a leading dollar sign i.e $a. Unlike other scripting languages like Java, C etc. no data type keyword is used along to define variable.
>> Variables are automatic parsing type in PHP i.e. they convert from one data type another whenever its needed. There, is no need to parse variables explicitly.
>> PHP has a total of eight data types which we use to construct our variables:
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).
The first five are simple types, and the next two (arrays and objects) are compound - the compound types can package up other arbitrary values of arbitrary type, whereas the simple types cannot.
Example declaration of a variable:
$a = 10; // Integer type Variable
$b = 34.5; // Float type Variable
$c = 'Hello World!'; // String type Variable
No comments:
Post a Comment