PHP Interview Question Set 8

Categories: PHP

 How do you connect MySQL database with PHP?

There are two methods to connect MySQL database with PHP. Procedural and object-oriented style.


How to create connection in PHP?

The mysqli_connect() function is used to create a connection in PHP.

resource mysqli_connect (server, username, password)       


How to create database connection and query in PHP?

Since PHP 4.3, mysql_reate_db() is deprecated. Now you can use the following 2 alternatives.

  1. mysqli_query()
  2. PDO::_query()


How can we increase execution time of a PHP script?

By default, the maximum execution time for PHP scripts is set to 30 seconds. If a script takes more than 30 seconds, PHP stops the script and returns an error.

You can change the script run time by changing the max_execution_time directive in the php.ini file.

When a script is called, set_time_limit function restarts the timeout counter from zero. It means, if default timer is set to 30 sec, and 20 sec is specified in function set_time_limit(), then script will run for 45 seconds. If 0sec is specified in this function, script takes unlimited time.



What are the different types of errors in PHP?

There are 3 types of error in PHP.


  1. Notices:These are non-critical errors. These errors are not displayed to the users.
  2. Warnings:These are more serious errors, but they do not result in script termination. By default, these errors are displayed to the user.
  3. Fatal Errors:These are the most critical errors. These errors may cause due to immediate termination of script.


How to stop the execution of PHP script?

The exit() function is used to stop the execution of PHP script.


What are the encryption functions in PHP?

CRYPT() and MD5()


What is htaccess in PHP?

The .htaccess is a configuration file on Apache server. You can change configuration settings using directives in Apache configuration files like .htaccess and httpd.conf.


Explain PHP explode() function.

The PHP explode() function breaks a string into an array.


Explain PHP split() function.

The PHP split() function splits string into an array by regular expression.

Top Blogs
PHP freshers Interview Questions PHP Interview Questions and Answers for Freshers & Experienced Published at:- PHP Tutorial From beginner Published at:- PHP Interview Question Set 1 Published at:- PHP Interview Question Set 3 Published at:- PHP Interview Question Set 4 Published at:- PHP Interview Question Set 6 Published at:- PHP Interview Question Set 7 Published at:- PHP Interview Question Set 8 Published at:- PHP Interview Question Set 9 Published at:- Top 5 PHP Structures Published at:- 8 Motivations To pick Php web Advancement for IT Business Published at:-
R4R.co.in Team
The content on R4R is created by expert teams.