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 -
Question:- When a session is begun what following things are happen?
Answer:- 1. PHP first makes two duplicates of one of a kind session id for that particular session of the client which is an arbitrary string of 32 hexadecimal numbers, for example, 3c7foj34c3jjhkyepop2fc937e3443. 2. One copy of unique session id automatically sent to the user?s computer for the sake of synchronization in future ahead, and one copy is being maintained at server side till the session is running. 3. Whenever you want to access the page of website or web app, then session id of the current user will be associated with the HTTP header, and that will be compared by the session id which is being maintained at the server. After completing the comparison process, you can easily access the page of the website or web app 4. A session ends when the user closes the browser, or after leaving the site, the server will terminate the session after a predetermined period, commonly 30 minutes duration.
Question:- What is PHP session_start() and session_destroy() function?
Answer:- 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.
Question:- What is PHP session_start() and session_destroy() function?
Answer:- 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.
Question:- What is the difference between session and cookie?
Answer:- The main difference between session and cookie is that cookies are stored on users computer in the text file format while sessions are stored on the server side. Cookies cant hold multiple variables, on the other hand, Session can hold multiple variables. You can manually set an expiry for a cookie, while session only remains active as long as browser is open.
