PHP interview questions, Part 2

  1. How can we repair a MySQL table?
  2. What are the advantages of stored procedures, triggers, indexes?
  3. What is the maximum length of a table name, database name, and fieldname in MySQL?
  4. How many values can the SET function of MySQL take?
  5. What are the other commands to know the structure of table using MySQL commands except explain command?
  6. How many tables will create when we create table, what are they?
  7. What is the purpose of the following files having extensions 1) .frm 2) .myd 3) .myi? What do these files contain?
  8. What is maximum size of a database in MySQL?
  9. Give the syntax of Grant and Revoke commands?
  10. Explain Normalization concept?
  11. How can we find the number of rows in a table using MySQL?
  12. How can we find the number of rows in a result set using PHP?
  13. How many ways we can we find the current date using MySQL?
  14. What are the advantages and disadvantages of Cascading Style Sheets?
  15. What type of inheritance that PHP supports?
  16. How can increase the performance of MySQL select query?
  17. The structure of table view buyers is as follows:
    +----------------+-------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +----------------+-------------+------+-----+---------+----------------+
    | user_pri_id | int(15) | | PRI | NULL | auto_increment |
    | userid | varchar(10) | YES | | NULL | |
    +----------------+-------------+------+-----+---------+----------------+
    

    the value of user_pri_id the last row 2345 then What will happen in the following conditions?

    Condition1: Delete all the rows and insert another row then. What is the starting value for this auto incremented field user_pri_id ,
    Condition2: Delete the last row(having the field value 2345) and insert another row then. What is the value for this auto incremented field user_pri_id

  18. What are the advantages/disadvantages of MySQL and PHP?
  19. What is the difference between GROUP BY and ORDER BY in Sql?
  20. What is the difference between char and varchar data types?
  21. What is the functionality of md5 function in PHP?
  22. How can I load data from a text file into a table?
  23. How can we know the number of days between two given dates using MySQL?
  24. How can we know the number of days between two given dates using PHP?
  25. How can we change the name of a column of a table?
  26. How can we change the name and data type of a column of a table?
  27. What are the differences between drop a table and truncate a table?
  28. When you want to show some part of a text displayed on an HTML page in red font color, what different possibilities are there to do this? What are the advantages/disadvantages of these methods?
  29. When viewing an HTML page in a Browser, the Browser often keeps this page in its cache. What can be possible advantages/disadvantages of page caching? How can you prevent caching of a certain page (please give several alternate solutions)?
  30. What are the different methods of passing data or information between two calls of a web page? What are the advantages/disadvantages of these methods?
  31. An Apache web server is running on a Linux system. Suddenly, the web server delivers the pages very slow. How could you find out possible reasons for that (when using system commands, please specify their names)?
  32. What are the different ways to login to a remote server? Explain the means, advantages and disadvantages?
  33. Please give a regular expression (preferably Perl/PREG style), which can be used to identify the URL from within a HTML link tag. Example: The regular expression should match the tag <A HREF=”http://www.yoursite.com/”> and give the URL (”http://www.yoursite.com /”) as a return result. Tags should also be matched if they contain other attributes than the HREF attribute.
  34. A select query over a large table runs very slow because of the growing number of entries in that table. What different measures could be taken to improve speed?
  35. A company wants to store their invoices in a database. They already have their customers and articles in that database. Both customer and article are each identified by an unique integer value. Please create the SQL statements for creating the necessary table(s) for storing the invoices in a MySQL database. An invoice should hold information like invoice number, customer, date, article(s) and quantity etc.
  36. For the database from the previous question, please give an SQL query which returns the invoice number of all invoices which contain the article with the number “1234″. The query should be able to run under a MySQL 4.0 database.
  37. How would you backup and restore a big MySQL database? What are the advantages of the approach which you have taken over the others?
  38. Create a PHP web script with the following attributes: on start, three HTML form elements are shown: an string input field, a checkbox field, a dropdown/pull down list with 5 elements and a submit button. On submission, the form should be redisplayed (while remaining all options/inputs as the user has selected/entered them). Additionally, the selections/inputs of the user should be displayed in text. Please solve this without the use of any external libraries.
  39. What is MIME?
  40. What is PEAR in PHP?
  41. How can I use the COM components in PHP?
  42. How can I load the DLLs dynamically?
  43. How many ways we can give the output to a browser?
  44. How can we know that a session is started or not?
  45. What is the default session time in PHP and how can I change it?
  46. What changes I have to done in PHP.ini file for file uploading?
  47. What are the differences between MySQL_fetch_array(), MySQL_fetch_object(), MySQL_fetch_row()?
  48. How can I set a cron and how can i execute it in Unix, Linux, and windows?
  49. Steps for the payment gateway processing?
  50. How many ways I can register the variables into session?
  51. Explain different types of errors in PHP (i.e. arguments in errorreporting function)?
  52. How many ways I can redirect a PHP page?
  53. List out different arguments in PHP header function?
  54. What type of headers have to add in the mail function in which file a attached?
  55. What is the difference between <?PHP and <? And which is preferable?
  56. What are the differences between include() and include_once() functions?
  57. Describe the importance of database abstraction layers in PHP and database connection?
  58. Explain MySQL optimization?
  59. What is the difference between using copy() and move() function in PHP file uploading?
  60. What is the difference between Reply-to and Return-path in the headers of a mail function?
  61. Explain about Type Juggling in PHP?
  62. How can I get the only name of the current executing file?
  63. How can I embed a Java program in PHP file and what changes have to be done in PHP.ini file?
  64. How can I find what type of images that the PHP version supports?
  65. 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 displayed the duplicated site name and how many times it is duplicated? …

Make sure you read Part 1 of PHP interview questions. For regular expressions, check out 8 Practical PHP Regular Expressions.

This entry was posted in Web dev. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

45 Comments on PHP interview questions, Part 2

  1. Shatabdi
    Posted 5/6/2005 at 8:15 am | Permalink

    1. How can we repair a MySQL table?
    The syntex for repairing a mysql table is
    REPAIR TABLENAME, [TABLENAME, ], [Quick],[Extended]

    This command will repair the table specified
    if the quick is given the mysql will do a repair of only the index tree if the extended is given it will create index row by row

  2. Shatabdi
    Posted 5/6/2005 at 8:20 am | Permalink

    3. maximum lenghth of mnames of database, table, columns

    database- 64
    table -64
    columns-64
    alias-255

  3. Shatabdi
    Posted 5/6/2005 at 8:22 am | Permalink

    4.How many values can the SET function of MySQL take?
    Mysql set can take zero or more values but at the maximum it can take 64 values

  4. Posted 5/14/2005 at 9:32 am | Permalink

    What are the other commands to know the structure of table using MySQL commands except explain command?
    describe table_name;

  5. Posted 5/14/2005 at 9:46 am | Permalink

    How can we find the number of rows in a table using MySQL?
    How can we find the number of rows in a result set using PHP?

    Use this for mysql
    >SELECT COUNT(*) FROM table_name;
    but if u r particular about no of rows with some special result
    do this
    >SELECT [colms],COUNT(*) FROM table_name [where u put conditions];

    and for PHP it cant be more simple

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

  6. Posted 5/14/2005 at 10:28 am | Permalink

    How many ways we can we find the current date using MySQL?
    SELECT CURDATE();

    CURRENT_DATE() = CURDATE()
    for time use
    SELECT CURTIME();
    CURRENT_TIME() = CURTIME()

  7. Posted 5/15/2005 at 1:00 am | Permalink

    Give the syntax of Grant and Revoke commands?
    The generic syntax for grant is as following
    > GRANT [rights] on [database/s] TO [username@hostname] IDENTIFIED BY [password]
    now rights can be
    a) All privilages
    b) combination of create, drop, select, insert, update and delete etc.
    we can grant rights on all databse by usingh *.* or some specific database by database.* or a specific table by database.table_name
    username@hotsname can be either username@localhost, username@hostname and username@%
    where hostname is any valid hostname and % represents any name, the *.* any condition
    password is simply the password of user

    The generic syntax for revoke is as following
    > REVOKE [rights] on [database/s] FROM [username@hostname]
    now rights can be as explained above
    a) All privilages
    b) combination of create, drop, select, insert, update and delete etc.

    username@hotsname can be either username@localhost, username@hostname and username@%
    where hostname is any valid hostname and % represents any name, the *.* any condition

  8. Posted 5/15/2005 at 1:02 am | Permalink

    The structure of table view buyers is as follows:
    +—————-+————-+——+—–+———+—————-+
    | Field | Type | Null | Key | Default | Extra |
    +—————-+————-+——+—–+———+—————-+
    | user_pri_id | int(15) | | PRI | NULL | auto_increment |
    | userid | varchar(10) | YES | | NULL | |
    +—————-+————-+——+—–+———+—————-+
    the value of user_pri_id the last row 2345 then What will happen in the following conditions?

    Condition1: Delete all the rows and insert another row then. What is the starting value for this auto incremented field user_pri_id ,
    Condition2: Delete the last row(having the field value 2345) and insert another row then. What is the value for this auto incremented field user_pri_id

    In botth cases let the value for auto increment field be n then next row will have value n+1 i.e. 2346

  9. Posted 5/15/2005 at 1:12 am | Permalink

    What is the difference between char and varchar data types?
    Set char to occupy n bytes and it will take n bytes even if u r storing avalue of n-m butes
    Set varchar to occupy n bytes and it will take only the required space and will not use the n bytes
    eg. name char(10) will waste 5 bytes if we store ‘kumar’, if each char takes a byte
    eg. name varchar(10) will just use 5 bytes if we store ‘kumar’, if each char takes a byte. rest 5 bytes will be free.

  10. Posted 5/15/2005 at 1:15 am | Permalink

    What is the functionality of md5 function in PHP?
    string md5(string)
    Calculate the md5 hash of a string. The hash is a 32-character hexadecimal number. I use it to generate keys which I use to identify users etc. If I add random no techniques to it the md5 generated now will be totally different for the same string I am using.

  11. Posted 5/15/2005 at 1:17 am | Permalink

    How can I load data from a text file into a table?
    The mysql provides a LOAD DATA INFILE syntax. U can load data from a file. Gr8 tool but u need to make sure that
    a) data is delimited
    b) u match the colms and data correctly
    dont use w/out first learning the syntax

  12. Posted 5/15/2005 at 1:24 am | Permalink

    How can we know the number of days between two given dates using MySQL?
    Use DATEDIFF()
    >SELECT DATEDIFF(NOW(),’1947-08-15′);
    will give u the exact no of days India got independence from British.

  13. Posted 5/15/2005 at 2:07 am | Permalink

    How can we know the number of days between two given dates using PHP?
    Simple arithmetic.
    $date1 = date(”Y-m-d”);
    $date2 = “1947-08-15″;
    $days = (strtotime() - strtotime()) / (60 * 60 * 24);
    echo ” No of $days we got independence from Britts”;

  14. Posted 5/15/2005 at 2:07 am | Permalink

    How can we change the name of a column of a table?
    How can we change the name and data type of a column of a table?
    this will change the name of colm
    > ALTER TABLE table_name CHANGE old_colm_name new_colm_name
    this will change the name of colm and also the datatype
    > ALTER TABLE table_name CHANGE old_colm_name new_colm_name [data type]

  15. Posted 5/15/2005 at 2:39 am | Permalink

    What are the differences between drop a table and truncate a table?
    >DROP TABLE table_name
    Will DELETE the table and DATA
    >TRUNCATE TABLE table_name
    Will DELETE the table DATA not the table definition

  16. Jigar
    Posted 5/19/2005 at 12:59 am | Permalink

    The structure of table view buyers is as follows:
    +—————-+————-+——+—–+———+—————-+
    | Field | Type | Null | Key | Default | Extra |
    +—————-+————-+——+—–+———+—————-+
    | user_pri_id | int(15) | | PRI | NULL | auto_increment |
    | userid | varchar(10) | YES | | NULL | |
    +—————-+————-+——+—–+———+—————-+
    the value of user_pri_id the last row 2345 then What will happen in the following conditions?

    Condition1: Delete all the rows and insert another row then. What is the starting value for this auto incremented field user_pri_id ,
    Condition2: Delete the last row(having the field value 2345) and insert another row then. What is the value for this auto incremented field user_pri_id

    Mr. Kumar has given its answer but if you have used mysql as backend and if you fire a query “delete from tablename” then in mysql it will reset auto index. so for condition one it will start from value 1.

    for condition 2 it will start from n+1

  17. Jigar
    Posted 5/19/2005 at 1:19 am | Permalink

    What is PEAR in PHP

    PEAR is short for “PHP Extension and Application Repository” and is pronounced just like the fruit. The purpose of PEAR is to provide:

    A structured library of open-sourced code for PHP users

    A system for code distribution and package maintenance

    A standard style for code written in PHP

    The PHP Foundation Classes (PFC),

    The PHP Extension Community Library (PECL),

    A web site, mailing lists and download mirrors to support the PHP/PEAR community

    PEAR is a community-driven project with the PEAR Group as the governing body. The project has been founded by Stig S. Bakken in 1999 and quite a lot of people have joined the project since then.

    http://pear.php.net/manual/en/introduction.php

  18. Nasim Abbas
    Posted 6/1/2005 at 1:14 am | Permalink

    A .66
    select count(id) id ,sitename from tbl_sites group by sitename having id>1;

  19. Sergej
    Posted 6/18/2005 at 11:21 am | Permalink

    What is the difference between GROUP BY and ORDER BY in Sql?

    ORDER BY [col1],[col2],…,[coln]; Tels DBMS according to what columns it should sort the result. If two rows will hawe the same value in col1 it will try to sort them according to col2 and so on.

    GROUP BY [col1],[col2],…,[coln]; Tels DBMS to group 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

  20. Sergej
    Posted 6/18/2005 at 11:30 am | Permalink

    39. What is MIME?

    MIME is Multipurpose Internet Mail Extensions is an internet standard for the format of e-mail. Howewer browsers also uses MIME standart to transmit files. MIME has a header wich is added to a begining of the data. When browser sees such header it shows the data as it would be a file (for example image)

    some mimes:
    audio/x-ms-wmp
    image/png
    aplication/x-shockwave-flash

  21. Posted 10/28/2005 at 4:28 am | Permalink

    44.How can we know that a session is started or not?
    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().

  22. Posted 10/28/2005 at 4:38 am | Permalink

    47.What are the differences between MySQL_fetch_array(), MySQL_fetch_object(), MySQL_fetch_row()?
    Ans:- MySQL_fetch_array()->Fetch a result row as an associative array,numeric array.
    MySQL_fetch_object()->Fetch a result row as an object.
    MySQL_fetch_row()->Fetch a result set as an array().

  23. Posted 11/15/2005 at 12:46 am | Permalink

    If we login more than one browser window at the same time with same user and after that we close one window then is the session is exist to other window or not.And if yes then why? or if no then why?

  24. Posted 11/24/2005 at 1:32 am | Permalink

    If we login more than one browser window at the same time with same user and after that we close one window then is the session is exist to other window or not.And if yes then why? or if no then why?

    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 u recreate connection, then also sesssion will continue in the browser.

  25. Abdu Rahiman
    Posted 1/14/2006 at 5:58 pm | Permalink

    What is the maximum storage capacity of Mysql data,
    Is Mysql not reliable, Why?

  26. m. sivakumar
    Posted 1/27/2006 at 2:12 am | Permalink

    What are the database files stored in system?
    Ans: data’s are stored in name.Myd
    table Structure are name.$frm
    Index tables are name.myi

  27. m. sivakumar
    Posted 1/27/2006 at 2:15 am | Permalink

    what is the difference between groupby and order by in mysql?

    Ans: Group by which is used to sort a table interms of colums
    order by which is used to index a table by colum value

  28. Moses Dinakran
    Posted 4/23/2006 at 11:58 pm | Permalink

    Question No 47.

    The difference between mysql_fetch_row() and mysql_fetch_array() is that the first returns the results in a numeric array ($row[0], $row[1] etc), while the latter returns a the results an array containing both numeric and associative keys ($row["name"], $row["email"] etc). mysql_fetch_object() returns an object ($row->name, $row->email etc).

  29. Posted 7/26/2006 at 5:20 am | Permalink

    difference between php4 and php5?

    php4 cannot support oops concepts and zend engine1 will be used

    in php5 support oops concepts and zends engine2 will be used
    error supporting will increased in php5
    xml and sqllite will be incresed in php5

  30. Posted 9/1/2006 at 2:16 pm | Permalink

    if i have to use more than one forms in more than one function in javascript and use it in a single html page,how should it be done

  31. Ashish Mathur
    Posted 10/27/2006 at 5:53 am | Permalink

    A.How can increase the performance of MySQL select query?

    We can use LIMIT to stop MySql for further search in table after we have received our required no. of records, also we can use LEFT JOIN or RIGHT JOIN instead of full join in cases we have related data in two or more tables.

  32. ALAGARSAMY
    Posted 12/8/2006 at 11:18 am | Permalink

    what about ob_start and ob_flush?
    Ans:
    ob_start is used to start the output buffer
    ob_flush is used to refresh or clear the output buffer

  33. Senthil
    Posted 12/24/2006 at 9:51 am | Permalink

    What is difference between MySql 4.0 and Mysql 5.0

  34. nilanjan banerjee
    Posted 2/23/2007 at 4:36 am | Permalink

    what the difference between
    mysql_connect and mysql_pconnect?

  35. alagarsamy
    Posted 4/16/2007 at 4:13 am | Permalink

    father of pms
    savan

  36. siddhant singh
    Posted 5/14/2007 at 5:02 am | Permalink

    ALL MYSQL QUERY WHICH USED IN PHP.

    1. mysql_connect
    2. mysql_pconnect
    3. mysql_select_db
    4. mysql_query
    5. mysql_fetch_array
    6. mysql_fetch_assocs
    7. mysql_fetch_row
    8. mysql_fetch_object
    9. mysql_close
    10. mysql_fetch_field
    11. mysql_fetch_leanth
    12. mysql_fetch_affected_rows
    13. mysql_create_db
    14. mysql_data_seek
    15. mysql_db_name
    16. mysql_db_query
    17. mysql_drop_db
    18. mysql_error
    19. mysql_field_flags
    20. mysql_field_len
    21. mysql_field_table
    22. mysql_field_type
    23. mysql_field_seek
    24. mysql_free_result
    25. mysql_insert_id
    26. mysql_first_dbs
    27. mysql_list_field
    28. mysql_ping
    29. mysql_hum_field
    30. mysql_read_escape

    can anyone tell me is this all complet query. which is used in php.

  37. Rakesh Chandel
    Posted 6/11/2007 at 11:01 am | Permalink

    mysql_pconnect() is used to make a persistence connection to a database means that we can not close a persistence connection using mysql_close() also if a connection is already opened mysql_pconnect will use that connection and will not create another connection.

  38. Manokaran
    Posted 7/24/2007 at 3:03 am | Permalink

    What is Normalization ?

    The process of simplifying a complex table into a simple form.

  39. Manokaran
    Posted 7/24/2007 at 4:37 am | Permalink

    How many can ways we redirect from php page?

    i. We can redirect from php page using header() function
    ex:

    header(”location:PAGE_NAME | PAGE_PATH”);

  40. Meganathan
    Posted 7/24/2007 at 6:41 am | Permalink

    Different types of error reporting in php ?

    error_reporting() function and its constant values
    —————————————————
    E_ERROR
    E_WARNING
    E_PARSE
    E_NOTICE
    E_CORE_ERROR
    E_CORE_WARNING
    E_COMPILE_ERROR
    E_COMPILE_WARNING
    E_USER_ERROR
    E_USER_WARNING
    E_USER_NOTICE
    E_ALL
    E_STRICT
    E_RECOVERABLE_ERROR

  41. Posted 11/17/2007 at 12:46 am | Permalink

    What is difference between MySql 4.0 and Mysql 5.0

    Mysql 4 doesn’t support Transaction, Triggers, Function and Procedures where as Mysql 5 does.

    Limit of Varchar in Mysql 4 is 255 . But in Mysql 5 it is more.

  42. Posted 11/27/2007 at 8:41 am | Permalink

    vardump();

    it should be return the variable type

  43. kathir
    Posted 12/5/2007 at 8:25 am | Permalink

    How can I get the only name of the current executing file?

    $_SERVER(”split_filename”)

  44. kalyan kumar challa,nellatur
    Posted 1/26/2008 at 3:17 pm | Permalink

    67:Explain about Type Juggling in PHP?
    Ans:
    some times php will perform an implicit data type conversion if values are expected to be of a perticular type.this is known as “type juggling”.

  45. Mikey
    Posted 4/14/2008 at 9:52 am | Permalink

    Seems to be an awful lot of mySQL questions in a list of PHP related goodies… where do you get these questions from?

One Trackback

  1. [...] done? Read the second set of interview questions on PHP, or leave comments [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*