Question:- How do you connect MySQL database with PHP?
Answer:- There are two methods to connect MySQL database with PHP. Procedural and object-oriented style.
Question:- How to create connection in PHP?
Answer:- The mysqli_connect() function is used to create a connection in PHP. resource mysqli_connect (server, username, password)
Question:- How to create database connection and query in PHP?
Answer:- Since PHP 4.3, mysql_reate_db() is deprecated. Now you can use the following 2 alternatives. mysqli_query() , PDO::_query()
Question:- How can we increase execution time of a PHP script?
Answer:- 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.
Question:- What are the different types of errors in PHP?
Answer:- 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.
Question:- How to stop the execution of PHP script?
Answer:- The exit() function is used to stop the execution of PHP script.
Question:- What are the encryption functions in PHP?
Answer:- CRYPT() and MD5()
Question:- What is htaccess in PHP?
Answer:- 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.
Question:- Explain PHP explode() function.
Answer:- The PHP explode() function breaks a string into an array.
Question:- Explain PHP split() function.
Answer:- The PHP split() function splits string into an array by regular expression.
Question:- How can we get IP address of a client in PHP?
Answer:- $_SERVER["REMOTE_ADDR"];
Question:- What is the meaning of a Persistent Cookie?
Answer:- A persistent cookie is permanently stored in a cookie file on the browsers computer. By default, cookies are temporary and are erased if we close the browser.
Question:- What is the use of the function imagetypes()?
Answer:- imagetypes() gives the image format and types supported by the current version of GD-PHP.
Question:- What are include() and require() functions?
Answer:- The Include() function is used to put data of one PHP file into another PHP file. If errors occur, then the include() function produces a warning but does not stop the execution of the script, and it will continue to execute. The Require() function is also used to put data of one PHP file to another PHP file. If there are any errors, then the require() function produces a warning and a fatal error and stops the script.
