Top 50 Php+mysql Interview Questions You Must Prepare 26.May.2022

To know the Image type use exif_imagetype ()
function To know the Image size use getimagesize ()
function To know the image width use imagesx ()
function To know the image height use imagesy() function t

HTML output
PHP, ASP, JSP, Servlet Function
Script Language output Function
Different Type of embedded Package to output to a browser

By using $_SERVER['HTTP_USER_AGENT'] variable.

When PHP is used on a Web server to handle a HTTP request, it converts information submitted in the HTTP request as predefined variables:

  • $_GET - Associate array of variables submitted with GET method.
  • $_POST - Associate array of variables submitted with POST method.
  • $_COOKIE - Associate array of variables submitted as cookies.
  • $_REQUEST - Associate array of variables from $_GET, $_POST, and $_COOKIE.
  • $_SERVER - Associate array of all information from the server and the HTTP request.

  SELECT DATEDIFF(’2007-03-07′,’2005-01-01′);

session_unregister — Unregister a global variable from the current session session_unset — Free all session variables

We can create MySQL database with the use of mysql_create_db(“Database Name”)

  • first of all instead of using select * from table1, use select column1, column2, column3.. from table1
  • Look for the opportunity to introduce index in the table you are querying.
  • use limit keyword if you are looking for any specific number of rows from the result set.

PHP: PHP 5.1.2
MySQL: MySQL 5.1
Apache: Apache 2.1

urlencode() returns the URL encoded version of the given string. URL coding converts special characters into % signs followed by two hex digits.

For example: urlencode(”10.00%”) will return “10%2E00%25″. URL encoded strings are safe to be used as part of URLs. urldecode() returns the URL decoded version of the given string.

Yes we can use include() more than one time in any page though it is not a very good practice.

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

Though i am not sure if this is wrong or not, With the exif extension you are able to work with image meta data.

Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.

mysql_fetch_array – Fetch a result row as an associative array, a numeric array, or both
mysql_fetch_assoc – Fetch a result row as an associative array
mysql_fetch_object – Fetch a result row as an object
mysql_fetch_row —- Get a result row as an enumerated array

Yes we can include that many times we want, but here are some things to make sure of:

(including abc.PHP, the file names are case-sensitive) there shouldn’t be any duplicate function names, me there should not be functions or classes or variables with the same name in abc.PHP and makeit.php.

:: is allowed to access methods that can perform static operations, i.e. those, which do not require object initialization.

A persistent cookie is a cookie which is stored in a cookie file permanently on the browser’s computer. By default, cookies are created as temporary cookies which stored only in the browser’s memory. When the browser is closed, temporary cookies will be erased. You should decide when to use temporary cookies and when to use persistent cookies based on their differences:

  • Temporary cookies can not be used for tracking long-term information.
  • Persistent cookies can be used for tracking long-term information.
  • Temporary cookies are safer because no programs other than the browser can access them.
  • Persistent cookies are less secure because users can open cookie files see the cookie values.


Reply-to: Reply-to is where to delivery the reply of the mail.

Return-path: Return path is when there is a mail delivery failure occurs then where to delivery the failure notification.

print $formatted;


ucwords() makes every first letter of every word capital, but it does not lower-case anything else. To avoid this, and get a properly formatted string, it’s worth using strtolower() first.

Crypto usage in PHP is simple, but that doesn’t mean it’s free. First off, depending on the data that you’re encrypting, you might have reasons to store a 32-bit value in the database instead of the 160-bit value to save on space. Second, the more secure the crypto is, the longer is the computation time to deliver the hash value. A high volume site might be significantly slowed down, if frequent md5() generation is required.

Here are three basic types of runtime errors in PHP:

  1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script – for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all – although you can change this default behavior.
  2. Warnings: These are more serious errors – for example, attempting to include() a file which does not exist. By default, these errors are displayed to the user, but they do not result in script termination.
  3. Fatal errors: These are critical errors – for example, instantiating an object of a non-existent class, or calling a non-existent function. These errors cause the immediate termination of the script, and PHP’s default behavior is to display them to the user when they take place.

Internally, these variations are represented by twelve different error types

The float property sets where an image or a text will appear in another element.

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

You can maintain two separate language file for each of the language. all the labels are put in both language files as variables and assign those variables in the PHP source. on runtime choose the required language option.

It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.

require_once() and include_once() are both the functions to include and evaluate the specified file only once. If the specified file is included previous to the present call occurrence, it will not be done again.

But require() and include() will do it as many times they are asked to do.


There are 2 ways to show some part of a text in red:

  1. Using HTML tag <font color=”red”>
  2. Using HTML tag <span style=”color: red”>

You can use functions: AES_ENCRYPT() and AES_DECRYPT() like:

AES_ENCRYPT(str, key_str)
AES_DECRYPT(crypt_str, key_str)

When the original if was followed by : and then the code block without braces.

For this purpose, you can first read the data from one server into session variables. Then connect to other server and simply insert the data into the database.

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

An online payment gateway is the interface between your merchant account and your Web site. The online payment gateway allows you to immediately verify credit card tractions and authorize funds on a customer’s credit card directly from your Web site. It then passes the traction off to your merchant bank for processing, commonly referred to as traction batching

The session support can be turned on automatically at the site level, or manually in each PHP page script:

  • Turning on session support automatically at the site level: Set session.auto_start = 1 in php.ini.
  • Turning on session support manually in each page script: Call session_start() function.

Since the data inside the single-quoted string is not parsed for variable substitution, it’s always a better idea speed-wise to initialize a string with single quotes, unless you specifically need variable substitution.

unlink() deletes the given file from the file system.

unset() makes a variable undefined.

PEAR is the next revolution in PHP. This repository is bringing higher level programming to PHP. PEAR is a framework and distribution system for reusable PHP components. It eases installation by bringing an automated wizard, and packing the strength and experience of PHP users into a nicely organised OOP library. PEAR also provides a command-line interface that can be used to automatically install “packages”

Total 5 types of tables we can create

  1. MyISAM
  2. Heap
  3. Merge
  4. INNO DB
  5. ISAM

MyISAM is the default storage engine as of MySQL 3.23 and as a result if we do not specify the table name explicitly it will be assigned to the default engine.

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

There is at least 3 ways to logon to a remote server:

Use ssh or telnet if you concern with security
You can also use rlogin to logon to a remote server.

You can find these specific information in PHP Manual.

The main idea behind this is to use Java script submit() function in order to submit the form without explicitly clicking any submit button. You can attach the document.formname.submit() method to onclick, onchange events of different inputs and perform the form submission. you can even built a timer function where you can automatically submit the form after xx seconds once the loading is done (can be seen in online test sites).

Data is stored in name.myd

Table structure is stored in name.frm

Index is stored in name.myi

  $date1 = date(‘Y-m-d’);  $date2 = ’2006-08-15′;  $days = (strtotime($date1) – strtotime($date2)) / (60 * 60 * 24);