Top 29 Lamp Interview Questions You Must Prepare 19.Mar.2024

Htmlentities() just converts the characters into HTML entities.

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.

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.

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..

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

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.

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

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

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]

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

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

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)

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

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

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

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.

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.

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.

$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

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.

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

The wer 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

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

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

Ex: session_register($login_id)

Session_unregister() Unregister a global variable from the current session

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.

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.

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

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

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