LAMP Interview Questions & Answers

  1. Question 1. Please State How To Submit A Form Without Using A Submit Button ?

    Answer :

    We can submit a form without using a submit button by having a JavaScript code linked to any event trigger of a form field. And just add the code document.form.submit() function to submit the form when the event is triggered.

  2. Question 2. State The Main Difference Between Mysql_fetch_array And Mysql_fetch_object ?

    Answer :

    Mysql_fetch_array will fetch all the matching records, whereas mysql_fetch_object will only fetch the first record that matches the query.

  3. HTML 5 Interview Questions

  4. Question 3. State The Main Difference Between $message And $$message ?

    Answer :

    $message is a name of a variable, whereas $$message is a variable with its name stored inside $message.

    For example if $message=”var”, then $$message is the same as $var

  5. Question 4. State The Main Difference Between Require And Include, Include_once ?

    Answer :

    The main difference is that when using require, it will throw a fatal error when a file is not found, whereas include and include_once will show a warning and continue to load the page.

  6. HTML 5 Tutorial

  7. Question 5. What Is The Difference Between The Functions Unlink And Unset?

    Answer :

    The Unlink() function deletes the file whereas Unset() makes a set variable as undefined.

  8. PHP Interview Questions

  9. Question 6. How You Will Define A Session ?

    Answer :

    A Session is a method to store some data to be used across multiple pages. In technical terms it is a logical object that is stored in the server to help you store data and can be accessed across multiple HTTP requests. Session is always temporary based on the session timeout set in your Apache Server.

  10. Question 7. How Do You Register The Variables Into A Session ?

    Answer :

    To register variables in a session, you need to use the session_register() function

    Ex: session_register($login_id)

  11. PHP Tutorial
    Adv Java Interview Questions

  12. Question 8. How You Will Find The Number Of Elements Present In An Array ?

    Answer :

    To find the no. of elements in an array, you can either use count() or sizeof() function

    Ex:  count($array) or sizeof($array).

  13. Question 9. Can You Encrypt Your Password In Php And How To Do It ?

    Answer :

    Yes, you can encrypt passwords and all kinds of data in PHP using md5() or sha() functions.

  14. PHP and Jquery Interview Questions

  15. Question 10. What Is A Trigger And Does Mysql Support Triggers ?

    Answer :

    A trigger is a database object that is associated with a particular table in a database. It gets activated automatically and performs when either INSERT, UPDATE, DELETE action occurs on the table.

    MySQL supports triggers from MySQL 5.0.2 version.

  16. Adv Java Tutorial

  17. Question 11. State The Main Difference Between Mysql_connect And Mysql_pconnect ?

    Answer :

    With mysql_connect, you open a database connection each time when the page loads, whereas with mysql_pconnect, connection gets established only once and provides access to the database across multiple requests.

  18. Angular JS Interview Questions

  19. Question 12. How To Repair A Table In Mysql ?

    Answer :

    To repair a table in MySQL you need to use the following query: 

    1. REPAIR TABLE {table name}
    2. REPAIR TABLE {table name}  QUICK / EXTENDED
    3. MySQL will do a repair of only the index tree, If QUICK is given
    4. MySQL will create index row by row, If EXTENDED is given.
  20. HTML 5 Interview Questions

  21. Question 13. Is Php A Case Sensitive Programming Language ?

    Answer :

    It is partially case sensitive, where we can use function and class names in case sensitive manner but variables need to be used in a case sensitive manner.

  22. PHP and Jquery Tutorial

  23. Question 14. How Can One Handle Loops In Php ?

    Answer :

    In PHP, you the looping statements like while, do while, for and for each.

  24. Question 15. Can You Execute A Php Script In Command Line ?

    Answer :

    Yes, we can execute a PHP script in command line with the following command line argument

    # php yourscript.php

    Where php is the command to execute the php script in a Command Line Interface (CLI)

  25. CakePHP Interview Questions

  26. Question 16. What Is Nl2br() ?

    Answer :

    nl2br() function inserts HTML line breaks before each newline in a string.

    For example nl2br(“How are you”) will return strings added with HTML line breaks before all new lines in a string, and the output will be like:

    How
    are
    you

  27. CakePHP Tutorial

  28. Question 17. How Can We Encrypt And Decrypt A Data Present In A Mysql Table Using Mysql ?

    Answer :

    To encrypt data in a mysql table, you can use the following: AES_ENCRYPT () and AES_DECRYPT ()

  29. LightWave 3D Interview Questions

  30. Question 18. What Are The Types Of Errors In Php And Explain Each One Of Them ?

    Answer :

    The types of errors in PHP are Notices, Warnings & Fatal Errors.

    Notices are less important errors that you don’t want to give much importance to it. Like errors that occur, when you try to access a variable that is not defined. If you change the notice errors to be not displayed, you won’t see these kinds of errors at all.

    Warnings are errors of some serious nature that demand your attention. Even though these errors are displayed to the user, the script will not terminated. Example of this error includes accessing a file that doesn’t exist.

    Fatal Errors are mission critical errors that result in immediate termination of your script. Examples of these errors include, calling an object of a non-existent class etc.

  31. PHP Interview Questions

  32. Question 19. What Is Htmlentities And What Is Their Functionality ?

    Answer :

    Htmlentities() just converts the characters into HTML entities.

  33. PHP7 Tutorial

  34. Question 20. What Is Urlencode() And Urldecode() ?

    Answer :

    urlencode() converts special characters into characters that are safe to be used in URL’s. Mostly they are converted into % signs along with 2 hex digits.

    For ex: urlencode(“20:00%) is converted into “25%2E00%25?”

    urldecode() does the opposite and returns the decoded string..

  35. Advanced Linux Interview Questions

  36. Question 21. What Php Image Functions Do You Use To Get The Properties Of An Image ?

    Answer :

    There are various php images functions that deals with images and you can use:

    • exif_imagetype() – To get the type of the image
    • getimagesize() – To get the size of the image
    • imagesx() – To get the width of the image
    • imagesy() – To get the height of the image
  37. Question 22. Can You Increase The Execution Time Of A Php Script ?

    Answer :

    Yes, we can use the max_execution_time variable to set the desired time you needed for executing a php script.

  38. Question 23. Can You Increase The Maximum Upload Size In Php ?

    Answer :

    Yes, we can use the upload_max_filesize variable to change the maximum size of a file you can upload.

  39. PHP7 Interview Questions

  40. Question 24. Please State How Can You Take A Backup Of The Whole Database In Mysql ?

    Answer :

    You can use the command line utility to take a backup of all the mysql table or a specific mysql table easily with the following:

    mysqldump –-user [user_name] –-password=[password] [database_name] > [dump_file_name]

  41. Adv Java Interview Questions

  42. Question 25. How To Destroy A Session Variable ?

    Answer :

    Session_unregister() Unregister a global variable from the current session

  43. Question 26. How Can We Unset The Variable Of A Session ?

    Answer :

    With the session_unset($variable_name) function, one can clear the session variable.

  44. Object Oriented Programming in PHP Interview Questions

  45. Question 27. How To Destroy A Cookie ?

    Answer :

    You just need to set the cookie to a previous date or time.

  46. PHP and Jquery Interview Questions

  47. Question 28. Please Explain What Is Wrong With This Query “select * From Table_name” ?

    Answer :

    You should never select all columns of a table unless needed and specify the columns only required in the query. The reason is that it will use a lot of memory to fetch the data, if the records are huge, when you are going to use only 2 or 3 fields from the table.

  48. Question 29. What Is Sql Injection And How Do You Deal With That ?

    Answer :

    SQL injection is a technique utilized by hackers to get access into your database by using malicious SQL statements. Using this, anyone can gain complete access to your database without any authorization or permission.

    To start with one need to use mysql_real_escape_string() to filter the user input data, before passing onto the sql statement.

  49. Fuel PHP Interview Questions

  50. Question 30. Please Explain The Output Of The Code Provided Below And Explain The Reasoning ?

    $a = 012; Echo $a / 4;

    Answer :

    The answer is 2.5.

    In PHP, whenever a number is prefixed with 0, it will be considered as an octal number, and hence the 012 octal number is equivalent to the decimal number 10, and so 10/4 is 2.5