DEVFYI - Developer Resource - FYI

PHP Interview Questions and Answers

Part:   1  2  3  4   5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20 

(Continued from previous part...)

What is the difference between ereg_replace() and eregi_replace()?

eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching alphabetic characters.


How do I find out the number of parameters passed into function9. ?

func_num_args() function returns the number of parameters passed in.


What is the purpose of the following files having extensions: frm, myd, and myi? What these files contain?

In MySQL, the default table type is MyISAM.
Each MyISAM table is stored on disk in three files. The files have names that begin with the table name and have an extension to indicate the file type.

The '.frm' file stores the table definition.
The data file has a '.MYD' (MYData) extension.
The index file has a '.MYI' (MYIndex) extension,


If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b?

100, it’s a reference to existing variable.


Write a query for the following question

The table tbl_sites contains the following data:

-----------------------------------------------------
Userid sitename country
------------------------------------------------------
1 sureshbabu indian
2 PHPprogrammer andhra
3 PHP.net usa
4 PHPtalk.com germany
5 MySQL.com usa
6 sureshbabu canada
7 PHPbuddy.com pakistan
8. PHPtalk.com austria
9. PHPfreaks.com sourthafrica
10. PHPsupport.net russia
11. sureshbabu australia
12. sureshbabu nepal
13. PHPtalk.com italy

Write a select query that will be displayed the duplicated site name and how many times it is duplicated? …

SELECT sitename, COUNT(*) AS NumOccurrences
FROM tbl_sites
GROUP BY sitename HAVING COUNT(*) > 1


How To Protect Special Characters in Query String?

If you want to include special characters like spaces in the query string, you need to protect them by applying the urlencode() translation function. The script below shows how to use urlencode():

<?php
print("<html>");
print("<p>Please click the links below"
." to submit comments about FYICenter.com:</p>");
$comment = 'I want to say: "It\'s a good site! :->"';
$comment = urlencode($comment);
print("<p>"
."<a href=\"processing_forms.php?name=Guest&comment=$comment\">"
."It's an excellent site!</a></p>");
$comment = 'This visitor said: "It\'s an average site! :-("';
$comment = urlencode($comment);
print("<p>"
.'<a href="processing_forms.php?'.$comment.'">'
."It's an average site.</a></p>");
print("</html>");
?>


Are objects passed by value or by reference?

Everything is passed by value.


What are the differences between DROP a table and TRUNCATE a table?

DROP TABLE table_name - This will delete the table and its data.

TRUNCATE TABLE table_name - This will delete the data of the table, but not the table definition.

(Continued on next part...)

Part:   1  2  3  4   5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20 

PHP Interview Questions and Answers