Close
All

Top 10 PHP Interview Questions and Answers

Top 10 PHP Interview Questions and Answers

In PHP, a session is a way to store data on the server that is accessible to all pages on a website. To create a session, you need to use the session_start() function. This function initializes a new session or resumes an existing one. Once a session is started, you can store data in the $_SESSION superglobal array.

For example:

1
session_start(); $_SESSION[‘username’] = ‘John’;
It’s important to note that the session_start() function must be called before any HTML or output is sent to the browser, otherwise it will not work.

  1. How do you perform a redirect in PHP?

In PHP, you can perform a redirect using the header() function. This function sends a raw HTTP header to the browser, which can be used to redirect the user to a different page.

Leave a Reply

Your email address will not be published. Required fields are marked *