Question:- How to read a file in PHP?
Answer:- PHP provides various functions to read data from the file. Different functions allow you to read all file data, read data line by line, and read data character by character. PHP file read functions are given below: fread(), fgets(), fgetc()
Question:- How to write in a file in PHP?
Answer:- PHP fwrite() and fputs() functions are used to write data into file. To write data into a file, you need to use w, r+, w+, x, x+, c or c+ mode.
Question:- How to delete file in PHP?
Answer:- The unlink() function is used to delete a file in PHP. bool unlink (string $filename)
Question:- What is the method to execute a PHP script from the command line?What is the method to execute a PHP script from the command line?
Answer:- You should just run the PHP command line interface (CLI) and specify the file name of the script to be executed as follows.
Question:- How to upload file in PHP?
Answer:- The move_uploaded_file() function is used to upload file in PHP. bool move_uploaded_file ( string $filename , string $destination )
Question:- How to download file in PHP?
Answer:- How to download file in PHP?
Question:- How can you send email in PHP?
Answer:- The mail() function is used to send email in PHP. bool mail($to,$subject,$message,$header);
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()
