PHP Interview Questions and Answers for Fresher

  1. What is the use of count function in MySQL?
    count() function is used for fetching the total number records in a table.
  2. How to send a mail in PHP?
    You can send an e-mail in PHP with mail() function or SMTP details.
  3. Explain what the meaning of a final class and a final method is?
    ‘final’ is initiated in PHP 5. Final class implies that this class can’t be enlarged and a final method can’t be overridden.
  4. How can you break PHP script?
    I can use exit() function for that.
  5. What is the default page in web server?
    Most of the times it will be index page.
  6. Explain how a comparison of objects done in PHP 5 is?
    I can use the operator ‘==’ to test two objects are mentioned from the corresponding class and have equal attributes and similar values. I can test if two objects are referring to the same instance of the corresponding class by the control of the identity operator ‘===’.
  7. What are the different types of errors in PHP?
    There are 4 basically types of error in PHP.
    Parse Error – Commonly caused due to syntax mistakes in codes.
    Fatal Error – These are basically runtime errors which are caused when you try to access what cannot be done.
    Warning Error – This error occurs when you try to include a file that is not present.
    Notice Error – This error occurs when you try to utilize a variable that has not been declared.
  8. What is session and why do we use it?
    A session is a super global variable that preserves data across subsequent pages. Session uniquely defines all users with a session ID. So it supports building a customized web application where user tracking is required.
  9. Describe how PHP and HTML can interact?
    Also, it is possible to make HTML into PHP scripts, and it is possible to transfer information from HTML to PHP.
  10. Explain which type of operation is required when passing values into an URL?
    To pass values by an URL, then you require to encode and to decode them applying urlencode () and htmlspecialchars().
  11. What is cookie and why do we use it?
    A cookie is a small piece of information stored in a client browser. It is a technique utilized to identify a user using the information stored in their browser. Utilizing PHP, we can both set and get COOKIE.

Leave a Reply