Jump to Navigation

035 - OOP Autoloading Objects

If you want to include classes for your script, you are using  require_once() statement.

require_once("calsses/Book.class.php");
require_once("classes/Employees.class.php");
require_once("calsses/Events.class.php");

You can eliminate the need to manually include each class file by defining the following function.

Example:

function __autoload($class) {

require_once("classes/$class_class.php");

}

PHP:

034 - OOP Static Class Members

You are writing a class that tracks the number of Web page visitors. You wouldn't want the visitor count to
reset to zero every time the class is instantiated, and therefore you would set the field to be of static scope.
Also static fields and methods are referred to using the self keyword and class name, rather than via this
and arrow operators.

Example:

class Visitor
{
private static $visitor =0;

PHP:

033 - OOP Setting properties

PHP5 version 5 and newer does offer some semblance of support for properties, done by overloading the __set and
__get methods. These methods are invoked if you attempt to reference a member variable that does not exist
within the class definition. Properties can be used for variety of purposes, such as to invoke an error message,
or even to extend the class by actually creating new variables on the fly.

__set() Example:

PHP:

032 - OOP Constructors

You often want to initialize certain fields and even trigger the execution of methods found when an object is newly
instantiated. There's nothing wrong with doing so immediately after instantiation.
But it would be easier if this were done for you automatically.Such a mechanism exists in OOP, known as a constructor.

PHP:

031 - Using SQL*Plus on Linux

To run SQL*Plus, or any Oracle-supplied command, you must have several environment variables set.
You can set these environment variables automatically at login by editing your login script, or
you can use an environment variable script built, When you installed Oracle Database XE, the installer
creates two scripts that define the environment variables for you.

Environment Variable Script(Bourne, Korn, Bash):
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server

Oracle:
Linux:

030 - To show kernel parameters

For Oracle instration, You should check the kernel parameters by the following command, though Oracle
installer checks the values, before installation will proceed.

[root@myserver ]# /sbin/sysctl -a | grep 'sem|shm|file-max|ip_local'

Oracle:
Linux:

029 - Apache optimizations for drupal

To reduce transfer sizes on your site is to enable Gzip compression of all pages that Apache serves. To do this, you can add the following to the end of your /etc/httpd/conf/httpd.conf

drupal:

028 - Backups and Remote Storage

There are various way to back up your precious Linux files:

Linux:

027 - Network Connections

With Linux, It's easy to establish network connections from one machine to another for remote logins
and file transfers.

Linux:

026 - rsync command for backup

The rsync command copies a set of files. It can make an exact copy, including file permissions and other
attributes (called mirroring), or it can just copy the data. It can run over a network or on a single machine.
rsync has many uses and over 50 options;
To mirror the directory D1 and its contents into another directory D2 on a single machine:

rsync [option] source dest

$ rsync -a D1 D2

Linux:

Pages

Subscribe to LAMP, Database and Cloud Technical Information RSS


Main menu 2

by Dr. Radut