 |
|
Oracle Database Tips by Donald Burleson
|
Basics
PHP is an interpreted scripting language embedded
in HTML pages and executed by the web server or on the command line.
Apache, IIS, and other web servers can execute PHP if the proper
options are selected during the installation. Installation of PHP is
not covered in this book. To obtain an accurate and complete guide for
this installation, access:
http://www.php.net .
As in any other programming language, PHP consists
of expressions connected by operators and handled by commands.
Operators are more or less the same as in the other scripting
languages. Operator tables have been taken from the PHP on-line manual
in their original format and are listed on the next two pages.
ASSOCIATIVELY |
OPERATORS |
Non-associative |
New |
Right |
[ |
Non-associative |
++-- |
Non-associative |
! ~ - (int) (float) (string) (array) (object)
@ |
Left |
* / % |
Left |
+-. |
Left |
<< >> |
Non-associative |
< <= > >= |
Non-associative |
== != === !== |
Left |
& |
Left |
^ |
Left |
| |
Left |
&& |
Left |
|| |
Left |
?: |
Right |
= += -= *= /= .= %= &= |= ^= <<= >>= |
Left |
And |
Left |
Xor |
Left |
Or |
Left |
, |
Table 1.1:
Operator Precedence
EXAMPLE |
NAME |
RESULT |
-$a |
Negation |
Opposite of $a. |
$a + $b |
Addition |
Sum of $a and $b. |
$a - $b |
Subtraction |
Difference of $a and $b. |
$a * $b |
Multiplication |
Product of $a and $b. |
$a / $b |
Division |
Quotient of $a and $b. |
$a % $b |
Modulus |
Remainder of $a divided by $b. |
Table 1.2:
Arithmetic Operators
EXAMPLE |
NAME |
RESULT |
$a == $b |
Equal |
TRUE if $a is equal to $b. |
$a === $b |
Identical |
TRUE if $a is equal to $b, and they are of
the same type. (introduced in PHP 4) |
$a != $b |
Not equal |
TRUE if $a is not equal to $b. |
$a <> $b |
Not equal |
TRUE if $a is not equal to $b. |
$a !== $b |
Not identical |
TRUE if $a is not equal to $b, or they are
not of the same type. (introduced in PHP 4) |
$a < $b |
Less than |
TRUE if $a is strictly less than $b. |
$a > $b |
Greater than |
TRUE if $a is strictly greater than $b. |
$a <= $b |
Less than or equal to |
TRUE if $a is less than or equal to $b. |
$a >= $b |
Greater than or equal to |
TRUE if $a is greater than or equal to $b.
|
Table 1.3:
Comparison Operators
Example |
Name |
Result |
$a and $b |
And |
TRUE if both $a and $b are TRUE. |
$a or $b |
Or |
TRUE if either $a or $b is TRUE. |
$a xor $b |
Xor |
TRUE if either $a or $b is TRUE, but not
both. |
! $a |
Not |
TRUE if $a is not TRUE. |
$a && $b |
And |
TRUE if both $a and $b are TRUE. |
$a || $b |
Or |
TRUE if either $a or $b is TRUE. |
Table 1.4:
Logical Operators
There is only one operator that can be regarded as
a string operator: "." (dot) represents concatenation as in the
following example:
$a="Using PHP ";
$b="with Oracle";
$c=$a.$b;
The value of the variable $c is "Using PHP
with Oracle".
PHP variables can be numeric or textual scalars,
arrays indexed by numbers, associative arrays (also known as "hashes")
and objects. All variables are prefixed by the dollar sign "$". There
is no distinction between arrays, hashes and scalars based on the
prefix, such as in Perl in which those are marked by @,% and $
respectively.
As in Perl, alphanumeric characters and underscore
(_) characters are allowed in the variable names. Variables are weakly
typed, meaning that the type cannot be declared. It is perfectly
acceptable to assign a string to the numeric variable, or vice versa.
Generally speaking, PHP distinguishes between
lowercase letters and uppercase letters. However, there are exceptions
which will be pointed out as they are encountered. Again, PHP is
embedded into HTML and can be mixed with HTML tags. Web servers
interpret everything between the <?php and ?> as a PHP routine and
passes it to the PHP interpreter either embedded in the server itself
or called as a CGI script.
The following contains a few examples of PHP
variables:
$a=5;
$b="Hello World!";
$c=array("a",5,3.14,"Hello World",NULL);
$d=TRUE;
See
code depot for complete scripts
This is an excerpt from the book
Easy Oracle PHP. You can get it
for more than 30% by buying it directly from the publisher and get
instant HTML-DB scripts from the code depot:
 |
Easy Oracle PHP
Create Dynamic Web Pages with Oracle Data
Includes online HTML-DB code depot
Buy it now for 30% off
- Only $19.95
|
HTML-DB support:
 |
For HTML-DB development support just call to gat an
Oracle Certified professional for all HTML-DB development
projects. |
|