Top 50 Php+mysql Interview Questions You Must Prepare 27.Jul.2024

Q1. How Can We Get The Properties (size, Type, Width, Height) Of An Image Using Php Image Functions?

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

Q2. How Many Ways We Can Give The Output To A Browser?

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

Q3. How Can We Get The Browser Properties Using Php?

By using $_SERVER['HTTP_USER_AGENT'] variable.

Q4. How To Get The Http Request In Php?

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.

Q5. How Can We Know The Number Of Days Between Two Given Dates Using Mysql?

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

Q6. How Can We Destroy The Session, How Can We Unset The Variable Of A Session?

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

Q7. How Can We Create A Database Using Php And Mysql?

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

Q8. How Can We Optimize Or Increase The Speed Of A Mysql Select Query?

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

Q9. What Are The Other Commands To Know The Structure Of A Table Using Mysql Commands Except Explain Command?

DESCRIBE table_name;

Q10. What Are The Current Versions Of Apache, Php, And Mysql?

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

Q11. What Is Meant By Urlencode And Urldecode?

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.

Q12. Can We Use Include ("abc.php") Two Times In A Php Page "makeit.php"?

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

Q13. How Do I Find Out The Number Of Parameters Passed Into Function9?

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

Q14. What Is The Php Predefined Variable That Tells The What Types Of Images That Php Supports?

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

Q15. Will Comparison Of String "10" And Integer 11 Work In Php?

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

Q16. In How Many Ways We Can Retrieve Data In The Result Set Of Mysql Using Php?

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

Q17. Tools Used For Drawing Er Diagrams.

Case Studio
Smart Draw

Q18. List Out Some Tools Through Which We Can Draw E-r Diagrams For Mysql.

Case Studio

Smart Draw

Q19. Can We Use Include(abc.php) Two Times In A Php Page Makeit.php?

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.

Q20. What's The Difference Between Accessing A Class Method Via -> And Via ::?

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

Q21. What Is A Persistent Cookie?

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.

 

Q22. What Is The Difference Between Reply-to And Return-path In The Headers Of A Mail Function?

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.

Q23. What's The Output Of The Ucwords Function In This Example?

$formatted = ucwords(”FYICENTER IS COLLECTION OF INTERVIEW QUESTIONS”);
print $formatted;

What will be printed is FYICENTER IS COLLECTION OF INTERVIEW QUESTIONS.

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.

Q24. So If Md5() Generates The Most Secure Hash, Why Would You Ever Use The Less Secure Crc32() And Sha1()?

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.

Q25. What Are The Different Types Of Errors In Php?

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

Q26. What Is 'float' Property In Css?

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

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

Q28. List Out The Predefined Classes In Php?

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.

Q29. If The Variable $a Is Equal To 5 And Variable $b Is Equal To Character A, What's The Value Of $$b?

5, it’s a reference to existing variable.

Q30. What's The Difference Between Include And Require?

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.

Q31. What Are The Differences Between Require And Include, Include_once?

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.

Q32. 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()

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

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

Q34. Suppose Your Zend Engine Supports The Mode <? ?> Then How Can U Configure Your Php Zend Engine To Support <?php ?> Mode ?

In php.ini file: set short_open_tag=on to make PHP support

Q35. How Can We Encrypt And Decrypt A Data Presented In A Table Using Mysql?

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

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

Q36. When Are You Supposed To Use Endif To End The Conditional Statement?

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

Q37. How Can I Retrieve Values From One Database Server And Store Them In Other Database Server Using Php?

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.

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

Q39. Steps For The Payment Gateway Processing?

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

Q40. How To Turn On The Session Support?

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.

Q41. Would You Initialize Your Strings With Single Quotes Or Double Quotes?

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.

Q42. What Is The Difference Between The Functions Unlink And Unset?

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

unset() makes a variable undefined.

Q43. What Is Meant By Pear In Php?

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”

Q44. What Are The Different Tables Present In Mysql, Which Type Of Table Is Generated When We Are Creating A Table In The Following Syntax:
Create Table Employee (eno Int(2),ename Varchar(10)) ?

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.

Q45. How Many Tables Will Create When We Create Table, What Are They?

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

Q46. What Are The Different Ways To Login To A Remote Server? Explain The Me, Advantages And Disadvantages?

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.

Q47. Functions In Imap, Pop3 And Ldap?

You can find these specific information in PHP Manual.

Q48. How Can We Submit A Form Without A Submit Button?

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

Q49. What Are The Mysql Database Files Stored In System ?

Data is stored in name.myd

Table structure is stored in name.frm

Index is stored in name.myi

Q50. How Can We Know The Number Of Days Between Two Given Dates Using Php?

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