Databases Reference
In-Depth Information
with the XHTML standard and should be avoided. Statements in a script are terminated
with a semicolon. Statements can be formatted for readability by including any amount
of whitespace—such as space characters, tab characters,or blank lines—in a script.
Comments can be included in a PHP script using the following styles:
// One-line comment
# Another one-line comment
/* A
multiple-line
comment */
Anything that appears after the // or # , or between the /* and */ characters, is ignored.
Variables are prefixed with a dollar sign ( $ ) and variable names are case-sensitive. PHP
has several variable types. Scalar variables contain one value; scalar types are integer ,
Boolean , string , and float (floating-point number). There are two compound types of
variable, array and object , that themselves contain scalar variables—possibly of dif-
ferent types.
Variables are automatically declared and given a type when they're first used. You don't
have to declare them beforehand; the type of a variable can change in a script. Values
are assigned to variables with a single = character:
// $x is an integer with the value 4
$x = 4;
// Now $x is a float
$x = 3.142;
// Now $x is a string
$x = "Selina";
// Now $x is a Boolean
$x = true;
// $y is an array of integers, strings, and Booleans
$y = array("hello", 1, 2, true, false, "cat");
Strings
PHP Strings are enclosed in double or single quotes. The following are identical:
$string = "Hello world";
$string = 'Hello world';
You can switch between quote styles for the convenience of including the other type
of quote in the string:
$string = "This string includes a single ' quote";
$string = 'This string includes a double " quote';
 
Search WWH ::




Custom Search