linuxStat PHP Documentation

Comments

There are three ways to include comments in a PHP program. Variables

A variable in PHP has three attributes: There is no explicit variable declaration in PHP. The first appearance
of a variable name in a PHP program creates an implicit declaration.
The type of the variable is determined from the context.

Example: Suppose I purchase 1005 Intel (INTC) shares in my
Fidelity Investments account, and I want to represent the information
in a PHP program. I can write:
$numberOfShares = 1005;
The above is an assignment statement in PHP. It contains a variable
named $numberOfShares. After the assignment statement is executed
$numberOfShares will have the value 1005. Since $numberOfShares
is being assigned an integer value, its type is integer.

A string can be enclosed by either single quote ' or double quote "
characters. When a string is enclosed by double quote " characters
a variable name appearing in the string is substituted by the value
of the variable.

A boolean variable can have one of two values: TRUE or FALSE.

An example PHP program contained inside an HTML document:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/transitional.dtd">
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<title>Executed on Dell Server, Intel Processor, created on HP laptop</title>
</head>
<body bgcolor="#0F243E" text="#FFFF00" lang=EN-US>
<font size="5">
<?php
# The following is a float variable.
$sharePrice = 18.05;
print "sharePrice has the value $sharePrice. <br>";
# Now redefine share price to be a string variable.
$sharePrice = 'Eighteen Dollars and five cents';
print "Closing price of one share of Intel (INTC) stock is $sharePrice.";
?>
</font>
</body>
</html>

Click the following link to execute the above PHP program by
my server's PHP interpreter.

Try the above example    Next    Index