void echo (string argument1 [, ...string argumentN])
The echo() statement operates similarly to print(), except for two differences. First, it cannot
be used as part of a complex expression because it returns void, whereas print() returns a
Boolean. Second, echo() is capable of outputting multiple strings. The utility of this particular
trait is questionable; using it seems to be a matter of preference more than anything else.
Nonetheless, it’s available should you feel the need. Here’s an example:
$heavyweight = "Lennox Lewis";
$lightweight = "Floyd Mayweather";
echo $heavyweight, " and ", $lightweight, " are great fighters.";
?>
boolean print (argument)
The print() statement is responsible for providing user feedback, and it is capable of displaying
both raw strings and variables. All of the following are plausible print() statements:
I love the summertime.");
?>
I love the $season.";
?>
I love the
summertime.";
?>
I love the ".$season."";
?>
The print() statement is responsible for providing user feedback, and it is capable of displaying
both raw strings and variables. All of the following are plausible print() statements:
I love the summertime.");
?>
I love the $season.";
?>
I love the
summertime.";
?>
I love the ".$season."";
?>
Whether for your own benefit or for that of a programmer later tasked with maintaining your
code, the importance of thoroughly commenting your code cannot be overstated. PHP offers
several syntactical variations, each of which is introduced in this section.
Single-line C++ Syntax
Comments often require no more than a single line. Because of its brevity, there is no need to
delimit the comment’s conclusion, because the newline (\n) character fills this need quite
nicely. PHP supports C++ single-line comment syntax, which is prefaced with a double-slash (//),
like this:
// Title: My PHP program
// Author: Jason
print "This is a PHP program";
?>
Shell Syntax
PHP also supports an alternative to the C++-style single-line syntax, known as shell syntax,
which is prefaced with a hash mark (#). Revisiting the previous example:
# Title: My PHP program
# Author: Jason
print "This is a PHP program";
?>
Multiple-Line C Syntax
It’s often convenient to include somewhat more verbose functional descriptions or other
explanatory notes within code, which logically warrant numerous lines. Although you could
preface each line with C++ or shell-style delimiters, PHP also offers a multiple-line variant that
both opens and closes the comment. Consider the following multiline comment:
/*
Title: My PHP Program
Author: Jason
Date: October 10, 2005
*/
?>
Multiline commentary syntax is particularly useful when generating documentation from
code, because it offers a definitive means for distinguishing between disparate comments, a
convenience not easily possible using single-line syntax.
code, the importance of thoroughly commenting your code cannot be overstated. PHP offers
several syntactical variations, each of which is introduced in this section.
Single-line C++ Syntax
Comments often require no more than a single line. Because of its brevity, there is no need to
delimit the comment’s conclusion, because the newline (\n) character fills this need quite
nicely. PHP supports C++ single-line comment syntax, which is prefaced with a double-slash (//),
like this:
// Title: My PHP program
// Author: Jason
print "This is a PHP program";
?>
Shell Syntax
PHP also supports an alternative to the C++-style single-line syntax, known as shell syntax,
which is prefaced with a hash mark (#). Revisiting the previous example:
# Title: My PHP program
# Author: Jason
print "This is a PHP program";
?>
Multiple-Line C Syntax
It’s often convenient to include somewhat more verbose functional descriptions or other
explanatory notes within code, which logically warrant numerous lines. Although you could
preface each line with C++ or shell-style delimiters, PHP also offers a multiple-line variant that
both opens and closes the comment. Consider the following multiline comment:
/*
Title: My PHP Program
Author: Jason
Date: October 10, 2005
*/
?>
Multiline commentary syntax is particularly useful when generating documentation from
code, because it offers a definitive means for distinguishing between disparate comments, a
convenience not easily possible using single-line syntax.
There is an Advanced Package Tool (apt-get) repository available on the Oracle Open Source
web site for Oracle Database XE. To include this repository, add the following to the file
/etc/apt/sources.list:
deb http://oss.oracle.com/debian unstable main non-free
libaio and bc are included in the repository, and will be installed from the repository if you
do not already have them installed.
If you download Oracle Database XE from the Oracle Technology Network
(http://otn.oracle.com/xe), you need to make sure that you have already installed the libaio
and bc packages. If you are using Ubuntu or Kubuntu, the bc package is installed by default
on the desktop version, but not on the server version.
To install Oracle Database XE on Debian, Ubuntu and Kubuntu, follow these steps:
1. Log in or su as root
su
Password:
2. Install Oracle Database XE
apt-get update
apt-get install oracle-xe
If you have not added the apt-get repository, you can download Oracle Database XE
from http://otn.oracle.com/xe, and run the following command to begin the install:
dpkg -i downloads/oracle-xe-universal_10.2.0.1-1.0_i386.deb
Oracle Database XE installs.
3. Configure the database
/etc/init.d/oracle-xe configure
4. Accept the default ports of 8080 for Application Express, and 1521 for the Database
Listener.
5. Enter and confirm the password for the default users.
6. Enter Y or N for whether you want the database to start automatically on reboot. The
database and database listener are configured and started.
web site for Oracle Database XE. To include this repository, add the following to the file
/etc/apt/sources.list:
deb http://oss.oracle.com/debian unstable main non-free
libaio and bc are included in the repository, and will be installed from the repository if you
do not already have them installed.
If you download Oracle Database XE from the Oracle Technology Network
(http://otn.oracle.com/xe), you need to make sure that you have already installed the libaio
and bc packages. If you are using Ubuntu or Kubuntu, the bc package is installed by default
on the desktop version, but not on the server version.
To install Oracle Database XE on Debian, Ubuntu and Kubuntu, follow these steps:
1. Log in or su as root
su
Password:
2. Install Oracle Database XE
apt-get update
apt-get install oracle-xe
If you have not added the apt-get repository, you can download Oracle Database XE
from http://otn.oracle.com/xe, and run the following command to begin the install:
dpkg -i downloads/oracle-xe-universal_10.2.0.1-1.0_i386.deb
Oracle Database XE installs.
3. Configure the database
/etc/init.d/oracle-xe configure
4. Accept the default ports of 8080 for Application Express, and 1521 for the Database
Listener.
5. Enter and confirm the password for the default users.
6. Enter Y or N for whether you want the database to start automatically on reboot. The
database and database listener are configured and started.
If you do not have a version of libaio over release 0.3.96, you need to install this library
before you can install Oracle Database XE.
To install Oracle Database XE:
1. Download the Oracle Database XE from http://otn.oracle.com/xe.
2. Log in or su as root
su
Password:
3. Install the RPM
rpm -ivh oracle-xe-univ-10.2.0.1-1.0.i386.rpm
Oracle Database XE installs.
4. Configure the database
/etc/init.d/oracle-xe configure
5. Accept the default ports of 8080 for Application Express, and 1521 for the Database
Listener.
6. Enter and confirm the password for the default users.
7. Enter Y or N for whether you want the database to start automatically on reboot. The
database and database listener are configured and started.
If you use the Oracle Unbreakable Linux Network and have the Oracle Software channel
enabled, you can install Oracle XE with:
up2date oracle-xe
After this download completes, follow the configuration step 4 onwards.
before you can install Oracle Database XE.
To install Oracle Database XE:
1. Download the Oracle Database XE from http://otn.oracle.com/xe.
2. Log in or su as root
su
Password:
3. Install the RPM
rpm -ivh oracle-xe-univ-10.2.0.1-1.0.i386.rpm
Oracle Database XE installs.
4. Configure the database
/etc/init.d/oracle-xe configure
5. Accept the default ports of 8080 for Application Express, and 1521 for the Database
Listener.
6. Enter and confirm the password for the default users.
7. Enter Y or N for whether you want the database to start automatically on reboot. The
database and database listener are configured and started.
If you use the Oracle Unbreakable Linux Network and have the Oracle Software channel
enabled, you can install Oracle XE with:
up2date oracle-xe
After this download completes, follow the configuration step 4 onwards.
This chapter contains an overview of, and installation instructions for, Oracle Database 10g
Express Edition (Oracle Database XE). The installation instructions are given for Linux,
Windows, Debian, Ubuntu and Kubuntu.
Oracle Database Editions
There are a number of editions of the Oracle database, each with different features, licensing
options and costs. The Oracle database edition names are:
* Express Edition
* Standard Edition One
* Standard Edition
* Enterprise Edition
All the editions are built using the same code base. That is, they all have the same source
code, but different features are implemented in each edition. Enterprise Edition has all the
bells and whistles, whereas the Express Edition has a limited feature set, but still has all the
reliability and performance of the Enterprise Edition.
You could start off with the Express Edition, and, as needed, move up to another edition
as your scalability and support requirements change. You could do this without changing any
of your underlying table structure or code. Just change the Oracle software and you’re away.
There’s a comprehensive list of the features for each Oracle edition at
http://www.oracle.com/database/product_editions.html.
This book discusses working with Oracle Database XE. This is the free edition. Free to
download. Free to develop against. Free to distribute with your applications. Yes, that is free,
free, free!
Oracle Database XE
Oracle Database XE is available on 32-bit Windows and Linux platforms. Oracle Database
XE is a good choice for development of PHP applications that require a free, small footprint
database.
Oracle Database XE is available on the Oracle Technology Network
(http://otn.oracle.com/xe) for the following operating systems:
* Windows 2000 Service Pack 4 or later
* Windows Server 2003
* Windows XP Professional Service Pack 1 or later
Installing Oracle Database 10g Express Edition
22
* Red Hat Enterprise Linux RHEL3 and RHEL4
* Suse SLES-9
* Fedora Core 4
* Red Flag DC Server 5.0/MIRACLE LINUX V4.0/Haansoft Linux 2006 Server
(Asianux 2.0 Inside)
* Debian 3.1
The following libraries are required for the Linux-based operating systems:
* glibc release 2.3.2
* libaio release 0.3.96
There are some limitations with Oracle Database XE:
* 4GB of data
* Single database instance
* Single CPU used, even if multiple CPUs exist
* 1GB RAM used, even if more RAM is installed
Oracle Database XE has a browser-based management interface, Oracle Application Express.
Support for Oracle Database XE is through an Oracle Technology Network
(http://otn.oracle.com/) discussion forum, which is populated by peers and product experts.
You cannot buy support from Oracle for Oracle Database XE.
If you need a fully supported version for the Oracle database, you should consider Oracle
Standard Edition or Enterprise Edition. You can download all the editions of the Oracle
Database from the Oracle Technology Network, and use these for application development
and testing, but when you go production, you’ll need to pay Oracle for the license costs.
Express Edition (Oracle Database XE). The installation instructions are given for Linux,
Windows, Debian, Ubuntu and Kubuntu.
Oracle Database Editions
There are a number of editions of the Oracle database, each with different features, licensing
options and costs. The Oracle database edition names are:
* Express Edition
* Standard Edition One
* Standard Edition
* Enterprise Edition
All the editions are built using the same code base. That is, they all have the same source
code, but different features are implemented in each edition. Enterprise Edition has all the
bells and whistles, whereas the Express Edition has a limited feature set, but still has all the
reliability and performance of the Enterprise Edition.
You could start off with the Express Edition, and, as needed, move up to another edition
as your scalability and support requirements change. You could do this without changing any
of your underlying table structure or code. Just change the Oracle software and you’re away.
There’s a comprehensive list of the features for each Oracle edition at
http://www.oracle.com/database/product_editions.html.
This book discusses working with Oracle Database XE. This is the free edition. Free to
download. Free to develop against. Free to distribute with your applications. Yes, that is free,
free, free!
Oracle Database XE
Oracle Database XE is available on 32-bit Windows and Linux platforms. Oracle Database
XE is a good choice for development of PHP applications that require a free, small footprint
database.
Oracle Database XE is available on the Oracle Technology Network
(http://otn.oracle.com/xe) for the following operating systems:
* Windows 2000 Service Pack 4 or later
* Windows Server 2003
* Windows XP Professional Service Pack 1 or later
Installing Oracle Database 10g Express Edition
22
* Red Hat Enterprise Linux RHEL3 and RHEL4
* Suse SLES-9
* Fedora Core 4
* Red Flag DC Server 5.0/MIRACLE LINUX V4.0/Haansoft Linux 2006 Server
(Asianux 2.0 Inside)
* Debian 3.1
The following libraries are required for the Linux-based operating systems:
* glibc release 2.3.2
* libaio release 0.3.96
There are some limitations with Oracle Database XE:
* 4GB of data
* Single database instance
* Single CPU used, even if multiple CPUs exist
* 1GB RAM used, even if more RAM is installed
Oracle Database XE has a browser-based management interface, Oracle Application Express.
Support for Oracle Database XE is through an Oracle Technology Network
(http://otn.oracle.com/) discussion forum, which is populated by peers and product experts.
You cannot buy support from Oracle for Oracle Database XE.
If you need a fully supported version for the Oracle database, you should consider Oracle
Standard Edition or Enterprise Edition. You can download all the editions of the Oracle
Database from the Oracle Technology Network, and use these for application development
and testing, but when you go production, you’ll need to pay Oracle for the license costs.
connectoci8.php
$c = oci_connect('hr', 'hrpwd', '//localhost/XE');
$s = oci_parse($c, 'select city from locations');
oci_execute($s);
while ($res = oci_fetch_array($s)) {
echo $res['CITY'] . "
";
}
oci_close($c);
?>
When invoked in a web browser, it connects to Oracle as the demonstration user hr of the
Oracle XE database running on the local machine
$c = oci_connect('hr', 'hrpwd', '//localhost/XE');
$s = oci_parse($c, 'select city from locations');
oci_execute($s);
while ($res = oci_fetch_array($s)) {
echo $res['CITY'] . "
";
}
oci_close($c);
?>
When invoked in a web browser, it connects to Oracle as the demonstration user hr of the
Oracle XE database running on the local machine