PHP Interview Questions & Answers for experienced

PHP Interview Questions & Answers for experienced are provided here. TutorialsClass helps you to test your knowledge and enhance your experience.

Read PHP Interview Questions & Answers for experienced candidates to get your dream job.

How can we submit a form without a submit button?

Java script submit() function is used for submit form without submit button. For example: document.formname.submit()


What is PHP floor() function?

With the help of floor() function, we can convert a numeric value to the it’s next lower integer value.


Example of floor() function in PHP:


What is the difference between mysqli_fetch_array() and mysqli_fetch_object()?

Both PHP functions are used to fetch data from MYSQL database, but there is a difference between mysqli_fetch_array() and mysqli_fetch_object() output format.

With the help of mysqli_fetch_array() function, we can fetch a query’s result data row as an array.

Example of mysqli_fetch_array() Function:


While mysqli_fetch_object() function, we can fetch a query’s result data row as an object.

Example of mysqli_fetch_object() Function:


How can you pass a variable by reference in PHP?

By using an ampersand (&) sign in-front of the variable, we can pass the variable by reference.

Why or when to use variable by reference ?

When PHP function arguments are passed by value, and value is changed within function, it does not change variable value outside the function. To allow a function to modify its argument value outside the function, they must be passed by reference.

Example:

If we do not use value by reference (&), then the output will be: ‘This is a sample line,’


How you can force maximum execution time error in PHP?

We can use sleep function to consume PHP execution time and it will throw PHP error.


Output:

maximum execution time error in php


How to increase maximum execution time in PHP and WordPress

We mostly see that the maximum execution time of a PHP Script is 30 seconds. If a script takes more than 30 seconds to execute, it will throw the following Fatal error.
Fatal error: Maximum execution time of 30 seconds exceeded in ....

We can increase maximum execution time in PHP and WordPress by using various methods. In the following examples, we have increased maximum execution time to 360 seconds (6 minutes).

Method 1: By adding the code in a PHP file:

We can set the maximum execution time by adding this code in a PHP File. You must add this code in that file which is included earlier in all other pages. Then this function will increase maximum execution time in all those files.
For example, put this code in header (header.php), or configuration (config.php) if available.


Method 2: Inside the .htaccess file:

We can do the same thing inside the .htaccess file as well. Before editing this file, you make sure to have a backup of .htaccess.


Method 3: Inside the php.ini file:

We can also set the maximum execution time by adding this code in the php.ini file.


Method 4: Inside wp-config.php file in WordPress:

If you are using WordPress then you can place this code in wp-config.php file.


Note: These methods will only work if you are allowed to change PHP configuration by your Hosting Server.