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.
How to delete file in PHP?
The unlink() function is used to delete a file in PHP.
bool unlink (string $filename)
Explain setcookie() function in PHP?
PHP setcookie() function is used to set cookie with HTTP response. Once the cookie is set, you can access it by $_COOKIE superglobal variable.
Syntax:
bool setcookie ( string $name [, string $value [, int $expire = 0 [, string $path
[, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] )
Explain PHP variable length argument function
PHP supports variable length argument function. It means you can pass 0, 1 or n number of arguments in function. To do this, you need to use 3 ellipses (dots) before the argument name. The 3 dot concept is implemented for variable length argument since PHP 5.6.
What is PHP session_start() and session_destroy() function?
PHP session_start() function is used to start the session. It starts new or resumes the current session. It returns the current session if the session is created already. If the session is not available, it creates and returns new sessions.
How to get the length of string?
The strlen() function is used to get the length of the string.
What is the method to execute a PHP script from the command line?
You should just run the PHP command line interface (CLI) and specify the file name of the script to be executed as follows.
What is Cookies? How to create cookies in PHP?
A cookie is used to identify a user. A cookie is a little record that the server installs on the client’s Computer. Each time a similar PC asks for a page with a program, it will send the cookie as well. With PHP, you can both make and recover cookie value.
Some important points regarding Cookies:
- Cookies maintain the session id generated at the back end after verifying the user’s identity in encrypted form, and it must reside in the browser of the machine
- You can store only string values not object because you can’t access any object across the website or web apps
- Scope: – Multiple pages.
- By default, cookies are temporary and transitory cookie saves in the browser only.
- By default, cookies are URL particular means Gmail isn’t supported in Yahoo and the vice versa.
- Per site 20 cookies can be created in one website or web app
- The Initial size of the cookie is 50 bytes.
- The Maximum size of the cookie is 4096 bytes.
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.
- mysqli_query()
- PDO::_query()
Explain PHP explode() function.
The PHP explode() function breaks a string into an array.