PHP Interview Questions and Answers
Question - 71 : - How can we know the number of days between two given dates using MySQL?
Answer - 71 : - Use DATEDIFF()
SELECT DATEDIFF(NOW(),'2006-07-01');
Question - 72 : - How can we change the name of a column of a table?
Answer - 72 : - This will change the name of column:
ALTER TABLE table_name CHANGE old_colm_name new_colm_name
Question - 73 : - How can we change the data type of a column of a table?
Answer - 73 : - How can we change the data type of a column of a table?
This will change the data type of a column:
ALTER TABLE table_name CHANGE colm_name same_colm_name [new data type]
Question - 74 : - What is the difference between GROUP BY and ORDER BY in SQL?
Answer - 74 : - To sort a result, use an ORDER BY clause.
The most general way to satisfy a GROUP BY clause is to scan the whole table and create a new temporary table where all rows from each group are consecutive, and then use this temporary table to discover groups and apply aggregate functions (if any).
ORDER BY [col1],[col2],...[coln]; Tells DBMS according to what columns it should sort the result. If two rows will have the same value in col1 it will try to sort them according to col2 and so on.
GROUP BY [col1],[col2],...[coln]; Tells DBMS to group (aggregate) results with same value of column col1. You can use COUNT(col1), SUM(col1), AVG(col1) with it, if you want to count all items in group, sum all values or view average.
Question - 75 : - What is meant by MIME?
Answer - 75 : - MIME is Multipurpose Internet Mail Extensions is an Internet standard for the format of e-mail. However browsers also uses MIME standard to transmit files. MIME has a header which is added to a beginning of the data. When browser sees such header it shows the data as it would be a file (for example image)
Some examples of MIME types:
audio/x-ms-wmp
image/png
application/x-shockwave-flash
Multipurpose Internet Mail Extensions.
WWW's ability to recognize and handle files of different types is largely dependent on the use of the MIME (Multipurpose Internet Mail Extensions) standard. The standard provides for a system of registration of file types with information about the applications needed to process them. This information is incorporated into Web server and browser software, and enables the automatic recognition and display of registered file types.
Question - 76 : - How can we know that a session is started or not?
Answer - 76 : - A session starts by session_start() function.
This session_start() is always declared in header portion. it always declares first. then we write session_register().
Question - 77 : - What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?
Answer - 77 : - 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().
Question - 78 : - If we login more than one browser windows at the same time with same user and after that we close one window, then is the session is exist to other windows or not? And if yes then why? If no then why?
Answer - 78 : - Session depends on browser. If browser is closed then session is lost. The session data will be deleted after session time out. If connection is lost and you recreate connection, then session will continue in the browser.
Question - 79 : - What are the MySQL database files stored in system ?
Answer - 79 : - Data is stored in name.myd
Table structure is stored in name.frm
Index is stored in name.myi
Question - 80 : - What is the difference between PHP4 and PHP5?
Answer - 80 : - PHP4 cannot support oops concepts and Zend engine 1 is used.
PHP5 supports oops concepts and Zend engine 2 is used.
Error supporting is increased in PHP5.
XML and SQLLite will is increased in PHP5.