Question:- Explain some of the PHP array functions?
Answer:- There are many array functions in PHP: array(), array_change_key_case(), array_chunk(), count(), sort(), array_reverse(), array_search(), array_intersect()
Question:- What is the difference between indexed and associative array?
Answer:- The indexed array holds elements in an indexed form which is represented by number starting from 0 and incremented by 1. For example: $season=array("summer","winter","spring","autumn"); The associative array holds elements with name. For example: $salary=array("Sonoo"=>"350000","John"=>"450000","Kartik"=>"200000");
Question:- How to get the length of string?
Answer:- The strlen() function is used to get the length of the string.
Question:- Explain some of the PHP string functions?
Answer:- here are many array functions in PHP: strtolower(), strtoupper(), ucfirst(), lcfirst(), ucwords(), strrev(), strlen()
Question:- What are the methods to submit form in PHP?
Answer:- There are two methods GET and POST.
Question:- How can you submit a form without a submit button?
Answer:- You can use JavaScript submit() function to submit the form without explicitly clicking any submit button.
Question:- What are the ways to include file in PHP?
Answer:- PHP allows you to include file so that page content can be reused again. There are two ways to add the file in PHP. include require
Question:- Differentiate between require and include?
Answer:- Require and include both are used to include a file, but if data is not found include sends warning whereas require sends Fatal error.
Question:- Explain setcookie() function in PHP?
Answer:- PHP setcookie() function is used to set cookie with HTTP response. Once the cookie is set, you can access it by $_COOKIE superglobal variable.
Question:- What is Syntax of setcookie() function in PHP?
Answer:- bool setcookie ( string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] )
Question:- How can you retrieve a cookie value?
Answer:- echo $_COOKIE ["user"];
Question:- What is a session?
Answer:- PHP Engine creates a logical object to preserve data across subsequent HTTP requests, which is known as session. Sessions generally store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same user. Simply, it maintains data of an user (browser).
Question:- What is $_SESSION in PHP?
Answer:- A session creates a file in a temporary directory on the server where registered session variables and their session id are stored. This data will be available to all pages on the site amid that visit. The area of the temporary record is controlled by a setting in the php.ini document called session.save_path. At the point when a session is begun following things happen -
