PHP QUESTIONS WITH ANSWER


Q.1 How can we repair a MySQL table?


ANSWER: The syntex for repairing a mysql table is:

REPAIR TABLE tablename
REPAIR TABLE tablename QUICK
REPAIR TABLE tablename EXTENDED

This command will repair the table specified.
If QUICK is given, MySQL will do a repair of only the index tree.
If EXTENDED is given, it will create index row by row.

Q.2 What is the difference between $message and $$message?

ANSWER 1: $message is a simple variable whereas $message is a reference variable. Example:
$user = ‘bob’

is equivalent to

$holder = ‘user’;
$holder = ‘bob’;

ANSWER2:
They are both variables. But $message is a variable with a fixed name. $message is a variable who’s name is stored in

$message. For example, if $message contains “var”, $message is the same as $var.


Q.3 What’s the difference between md5(), crc32() and sha1() crypto on PHP?

ANSWER:The major difference is the length of the hash generated. CRC32 is, evidently, 32 bits, while sha1() returns a 128 bit value, and md5() returns a 160 bit value. This

is important when avoiding collisions.

Q.4 How can we find the number of rows in a result set using PHP?

ANSWER:Here is how can you find the number of rows in a result set in PHP:

$result = mysql_query($any_valid_sql, $database_link);
$num_rows = mysql_num_rows($result);
echo “$num_rows rows found”;

Q.5 How many ways we can we find the current date using MySQL?

ANSWER:SELECT CURDATE();
SELECT CURRENT_DATE();
SELECT CURTIME();
SELECT CURRENT_TIME();