Creating a sample class

The following is the sample program using classes and objects.
In this program, a class is created and its member variable is
assigned a value.

class test
var $a;

function assign($val)
$this->a = $val;

function display()
echo “Value ” . $this->a;


$t = new test();
$t->a= 3000;

The output of the above program will be:

Value: 3000

Connecting Oracle with PHP

In some instances, we need to connect Oracle with PHP.
The following is the sample program that connects oracle with php and
fetches data from an oracle table.


$dbuser = “username”;
$dbpass = “password”;
$dbserver = “//servername”;

$c=OCILogon($dbuser, $dbpass, $dbserver);

if (!$c) {
$err = OCIError();
echo “Oracle Connect Error ” . $err[text];

$query =”SELECT * from employee”;
$res= OCIParse($c,$query);
OCI_Execute($res, OCI_DEFAULT);


$emp_id = OCIResult($res, “EMP_ID”);
echo “Employee id: ” . $emp_id;