Friday, 9 April 2010

How to Declare a Class and Initializing a Class Object ?

Declaring Class in PHP5:
In PHP5 you create a new class using "class" keyword.
The basic declaration of a class:


class myClass
{
   public function getAge()
   {
      echo "Inside Method";
   }
}
 
Initializing an Class Object in PHP5

To access the class from the outside world i.e. outside the scope of
class; you will need to create an object instance of the class. This
can be achieved using "new" operator.

Initializing Class 

class myClass
{
   public function myAge()
   {
      echo "Inside Method";
   }
}     
$myClassObj = new myClass();
 
//Calling class method... 
$myClassObj->myAge(); 

How to check Session is expire or not during Aajx Call?

As I told you in my previous post, there are some status code you found in during Ajax Call.
 
if(xmlhttp.status == 500) {
// That means session has been lost..
// Do your task whatever you want to do here... 
}
Cheers!

Difference b/w Synchronous and Asynchronous?

Suppose there are two process A and B are running and process B are depends upon the process A result.

If two processes are running Synchronously, it means that second process will wait until or unless first process complete.

If two processes are running Asynchronously, it means second process will not wait for second process result and will be executed.

Cheers!

Some Important Tips on Ajax

By default in a open method, you found something like this:
open("GET",url,false);

method: the type of request: GET or POST
url: the location of the file
boolean: true (asynchronous) or false (synchronous)

Here last parameter is false it means process will be synchronous.

To make process Asynchronous, make true instead of false.

Cheers!

What is the Status means in Ajax term?

Whenever response return it also return status.

for example:

if (xmlhttp.status == 200) // i.e., OK
if (xmlhttp.status == 404) // i.e., Page not found.
if (xmlhttp.status == 500) // i.e., Session expired.

Cheers!

What are the means of readyState in Ajax

There are four type of readyState exist in Ajax:

0: not initialized.
1: connection established.
2: request received.
3: answer in process.
4: finished. 
 
 
Cheers! 

Wednesday, 7 April 2010

What is the difference between the functions unlink and unset?

unlink() is a function for file system handling. It will simply delete the file in context.

unset() is a function for variable management. It will make a variable undefined.

Cheers!