What is the default session time in php and how can I change it?

The default session time in php is until closing of browser

What are the MySQL database files stored in system ?

Data is stored in name.myd
Table structure is stored in name.frm
Index is stored in name.myi

What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?

mysql_fetch_array() -> Fetch a result row as a combination of associative array and regular array.
mysql_fetch_object() -> Fetch a result row as an object.
mysql_fetch_row() -> Fetch a result set as a regular array().

What Is a Persistent Cookie?

A persistent cookie is a cookie which is stored in a cookie file permanently on the browser's computer. By default, cookies are created as temporary cookies which stored only in the browser's memory. When the browser is closed, temporary cookies will be erased. You should decide when to use temporary cookies and when to use persistent cookies based on their differences:
*Temporary cookies can not be used for tracking long-term information.
*Persistent cookies can be used for tracking long-term information.
*Temporary cookies are safer because no programs other than the browser can access them.
*Persistent cookies are less secure because users can open cookie files see the cookie values.

What function can be used to encode passwords for storage in the database

The md5() function creates a one-way encoding of the password.

Where is the data for a cookie stored?

Cookies are stored on the web user's hard drive.

How can we get second of the current time using date function?

$second = date("s");

php and pdf

 Documents and Pages

A PDF document is made up of a number of pages. Each page contains text and/or images.Put text onto
 the pages, and send the pages back to the browser when you're done.

 
 
<?php

require("../fpdf/fpdf.php"); // path to fpdf.php

$pdf = new FPDF(  );
$pdf->AddPage(  );
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello Out There!');
$pdf->Output(  );

?>
 follows the basic steps involved in creating a PDF document.

The cell concept in the FPDF Library is that of a rectangular area on the page that you can create and control.
 This cell can have a height, width, a border, and of course can contain text.
The basic syntax for the cell method is as follows:
Cell(float w [, float h [, string txt [, mixed border [, int ln [, 
string align [, int fill [, mixed link]]]]]]])

The first option is the width, then the height, then the text to be outputted, then border, then new line control, then its alignment, any fill colour for the text, and finally if you want the text to be an HTML link. So, for example, if we want to change our original example to have a border and be center
 aligned we would change the cell code to the following:
$pdf->Cell(90,10,'Hello Out There!',1,0,'C');

The cell method is used extensively while generating PDF documents with fpdf,

Demonstrating coordinates and line management

<?php
require("../fpdf/fpdf.php");

$pdf = new FPDF('P', 'in', 'Letter');
$pdf->AddPage(  );
$pdf->SetFont('Arial','B',24);
// Cell(W, H, 'text', Border, Return, 'Allign') - basic syntax
$pdf->Cell(0,0,'Top Left!',0,1,'L');
$pdf->Cell(6,0.5,'Top Right!',1,0,'R');
$pdf->ln(4.5);
$pdf->Cell(0,0,'This is the middle!',0,0,'C');
$pdf->ln(5.3);
$pdf->Cell(0,0,'Bottom Left!',0,0,'L');
$pdf->Cell(0,0,'Bottom Right!',0,0,'R');
$pdf->Output(  );
?>

Declaring a Class

To design your program or code library in an object-oriented fashion, you'll need to define your own classes, using the class keyword.
A class definition includes the class name and the properties and methods of the class. Class names are case-insensitive and must conform to the rules for PHP identifiers. The class name stdClass is reserved. Here's the syntax for a class definition:
 
 
class classname [ extends baseclass ]
    {
        [ var $property [ = value ]; ... ]

        [ function functionname (args) {
              // code
          }
          ...
        ]
    }
 
 

Declaring Methods

A method is a function defined inside a class. Although PHP imposes no special restrictions, most methods act only on data within the object in which the method resides. Method names beginning with two underscores (_ _) may be used in the future by PHP (and are currently used for the object serialization methods _ _sleep( ) and _ _wakeup( ), described later in this chapter, among others), so it's recommended that you do not begin your method names with this sequence.
Within a method, the $this variable contains a reference to the object on which the method was called. For instance, if you call $rasmus->birthday( ) inside the birthday( ) method, $this holds the same value as $rasmus. Methods use the $this variable to access the properties of the current object and to call other methods on that object.

Here's a simple class definition of the Person class that shows the $this variable in action:
class Person { var $name; function get_name ( ) { return $this->name; } function set_name ($new_name) { $this->name = $new_name; } }
 
 
As you can see, the get_name( ) and set_name( ) methods use $this to access and set the $name property of the current object.
To declare a method as a static method, use the static keyword. Inside of static methods the variable $this is not defined. For example:

class HTML_Stuff {
static function start_table( ) {
echo "<table border='1'>\n";
 } static function end_table ( ) {
echo "</table>\n";
}
}
HTML_Stuff::start_table( ); // print HTML table rows and columns HTML_Stuff::end_table( );


Declaring Properties

In the previous definition of the Person class, we explicitly declared the $name property. Property declarations are optional and are simply a courtesy to whoever maintains your program. It's good PHP style to declare your properties, but you can add new properties at any time.
Here's a version of the Person class that has an undeclared $name property:
    class Person {
        function get_name (  )
        {
            return $this->name;    }

        function set_name ($new_name) {
            $this->name = $new_name;
        }
    }

You can assign default values to properties, but those default values must be simple constants:
    var $name = 'J Doe';       // works
    var $age  = 0;             // works
    var $day  = 60*60*24;      // doesn't work

Using access modifiers, you can change the visibility of properties. Properties that are accessible outside the object's scope should be declared public; properties on an instance that can only be accessed by methods within the same class should be declared private.
 

Sorting One Array at a Time

PHP functions for sorting an array
Effect
Ascending
Descending
User-defined order
Sort array by values, then reassign indices starting with 0
sort( )
rsort( )
usort( )
Sort array by values
asort( )
arsort( )
uasort( )
Sort array by keys
ksort( )
krsort( )
uksort( )

The sort( ), rsort( ), and usort( ) functions are designed to work on indexed arrays because they assign new numeric keys to represent the ordering. They're useful when you need to answer questions such as, "What are the top 10 scores?" and "Who's the third person in alphabetical order?" The other sort functions can be used on indexed arrays, but you'll only be able to access the sorted ordering by using traversal functions such as foreach and next 

To sort names into ascending alphabetical order, you'd use this:
    $names = array('cath', 'angela', 'brad', 'dave');
    sort($names);                // $names is now 'angela', 'brad', 'cath', 'dave'

To get them in reverse alphabetic order, simply call rsort( ) instead of sort( ).
If you have an associative array mapping usernames to minutes of login time, you can use arsort( ) to display a table of the top three, as shown here:
    $logins = array('njt' => 415,
                    'kt'  => 492,
                    'rl'  => 652,
                    'jht' => 441,
                    'jj'  => 441,
                    'wt'  => 402);
    arsort($logins);
    $num_printed = 0;
    echo("<table>\n");
    foreach ($logins as $user => $time ) {
      echo("<tr><td>$user</td><td>$time</td></tr>\n");
      if (++$num_printed == 3) {
        break;                   // stop after three
      }
    }
    echo("</table>\n");
    <table>
    <tr><td>rl</td><td>652</td></tr>
    <tr><td>kt</td><td>492</td></tr>
    <tr><td>jht</td><td>441</td></tr>
    </table>

If you want that table displayed in ascending order by username, use ksort( ):
    ksort($logins);
    echo("<table>\n");
    foreach ($logins as $user => $time) {
      echo("<tr><td>$user</td><td>$time</td></tr>\n");
    }
    echo("</table>\n");
    <table>
    <tr><td>jht</td><td>441</td></tr>
    <tr><td>jj</td><td>441</td></tr>
    <tr><td>kt</td><td>492</td></tr>
    <tr><td>njt</td><td>415</td></tr>
    <tr><td>rl</td><td>652</td></tr>
    <tr><td>wt</td><td>402</td></tr>
    </table>

User-defined ordering requires that you provide a function that takes two values and returns a value that specifies the order of the two values in the sorted array. The function should return 1 if the first value is greater than the second, -1 if the first value is less than the second, and 0 if the values are the same for the purposes of your custom sort order.
 a program that lets you try the various sorting functions on the same data.