What is a final keyword in PHP and when it is used?

Posted by Prem Tiwari | Updated on | PHP Interview


The final keyword in PHP is used to mark either a class or a function as final. If a class is marked as final, it cannot be extended to use its properties or methods. It …

What is PDO?

Posted by Pinki | Updated on | PHP Interview


The full form of PDO is PHP Data Objects. It is a lightweight PHP extension that uses a consistence interface for accessing the database. Using PDO, a developer can easily switch from one database server …

What is URL rewriting?

Posted by Pinki | Updated on | PHP Interview


Appending the session ID in every local URL of the requested page for keeping the session information is called URL rewriting. The disadvantages of these methods are, it doesn’t allow persistence between the sessions and, …

Which library is used in PHP to do various types of Image work?

Posted by Pinki | Updated on | PHP Interview


Using the GD library, various types of image work can be done in PHP. Image work includes rotating images, cropping an image, creating image thumbnail, etc.

What is garbage collection?

Posted by Pinki | Updated on | PHP Interview


What is garbage collection? It is an automated feature of PHP. When it runs, it removes all session data which are not accessed for a long time. It runs on /tmp directory which is the …

What is a persistence cookie?

Posted by Pinki | Updated on | PHP Interview


A cookie file that is stored permanently in the browser is called a persistence cookie. It is not secure and is mainly used for tracking a visitor for long times. This type of cookie can …

What PSR Standards do you follow? Why would you follow a PSR standard?

Posted by Pinki | Updated on | PHP Interview


What PSR Standards do you follow and Why would you follow a PSR standard? One should folow a PSR because coding standards often vary between developers and companies. This can cause issues when reviewing or …

What are the __construct() and __destruct() methods in a PHP class?

Posted by Pinki | Updated on | PHP Interview


All objects in PHP have Constructor and Destructor methods built-in. The Constructor method is called immediately after a new instance of the class is being created, and it’s used to initialize class properties. The Destructor …

What are Traits in PHP?

Posted by Prem Tiwari | Updated on | PHP Interview


Traits are a mechanism that allows you to create reusable code in languages like PHP where multiple inheritance is not supported. A Trait cannot be instantiated on its own. It’s important that a developer knows …

What is the difference between GET and POST?

Posted by Prem Tiwari | Updated on | PHP Interview


GET displays the submitted data as part of the URL, during POST this information is not shown as it’s encoded in the request. GET can handle a maximum of 2048 characters, POST has no such …

What are the main error types in PHP and how do they differ?

Posted by Prem Tiwari | Updated on | PHP Interview


In PHP there are three main type of errors: Notices – Simple, non-critical errors that are occurred during the script execution. An example of a Notice would be accessing an undefined variable. Warnings – more important errors …

What is the use of mysqli_real_escape_string() function?

Posted by Pinki | Updated on | PHP Interview


mysqli_real_escape_string() function is used to escape special characters from the string for using a SQL statement Sample code:

How long does a PHP session last for?

Posted by Prem Tiwari | Updated on | PHP Interview


By default, session data will last for 24 minutes or 1440 seconds in PHP. But if you want, you can change the duration by modifying the value of gc_maxlifetime directive in php.ini file. To set …

How can you make a connection with MySQL server using PHP?

Posted by Prem Tiwari | Updated on | PHP Interview


You have to provide MySQL hostname, username, and password to make a connection with the MySQL server in mysqli_connect() method or declaring database object of the mysqli class. Example:

What is type casting and type juggling in PHP?

Posted by Prem Tiwari | Updated on | PHP Interview


What is type casting and type juggling in PHP? The way by which PHP can assign a particular data type for any variable is called typecasting. The required type of variable is mentioned in the …