What are the various methods to pass data from one web page to another web page?
Different methods to pass data from one web page to another:
1. Store the data in a session variable. By storing the data, the data can be passed from one page to another.
2. Store data in a cookie: By storing data in a persistent cookie, data can be passed from one form to another.
3. Set the data in a hidden field and post the data using a submit button.
Short note on passing parameter by reference and returning parameter by reference with examples.Passing parameter by reference:
In PHP, variables can be passed by reference so as to modify them. Variables, statements which have new and references returned from function can be passed.Example:
references returned from function
<?phpReturning parameter by reference:
Returning parameter by reference is used when a function to find to which variable a reference should be bound.Example:
$obj = new foo;
$myValue = &$obj->getValue(); // $myValue is a reference to $obj-value, which is 42.
$obj->value = 2;
How many ways I can redirect a PHP page?
1. Header function in PHP redirects to a new URLExample:
2. http_redirect() is also used to redirect to a new page or URL.Syntax:
void http_redirect ( [string url [, array params [, bool session = FALSE [, int status]]]] )
Here, the URL is the path of the new page. params can be some query parameters followed by whether the session information needs to be passed and the custom response status code.