1) swap value of a and b without using third variable ?
For integer values :
$a = 10;
$b = 25;
$a = $a + $b ; // a = 35
$b = $a – $b ; // b = 10
$a = $a – $b ; // a = 25
For any values :
list ($a , $b) = array ($b, $a);
2) difference between public and prviate ?
public scope to make that variable/function available from anywhere, other classes and instances of the object.
private scope when you want your variable/function to be visible in its own class only.
protected scope when you want to make your variable/function visible in all classes that extend current class including the parent class.
3)include & require difference ?
Include will includes a file each time it is called. when included file is not available it gives a warning.
Require is like include, but if the file included is not available a fatal error occurs and processing stops.
4)how to suppress warning errors ?
In PHP.ini we can set error setting to ~E_WARNING.
5)why class is needed ? how to call a method from another class ?
Classes are needed to represent the structure or behavior of any object.
- Class is a User Defined Data type.
- Class is a collection of data and methods.
and some technical analysis questions are asked based on some example code.