Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set object /variable to request scope using PHP

Tags:

php

I am java, j2ee developer. But new to PHP lang.

In Java Controller and Jsp , there is provision to add object in request attribute. like this ....

request.setAttribute("Object_key", Object);

Is there is such kind of provision in PHP, which add object/Variable in request. So these objects/Variables are available to next view page.

like image 267
Vicky Avatar asked Sep 25 '10 06:09

Vicky


People also ask

What is the scope of variable in PHP?

In PHP, variables can be declared anywhere in the script. The scope of a variable is the part of the script where the variable can be referenced/used.

What is a request scoped value?

A "request scoped variable" is an variable which is stored as an attribute of the HttpServletRequest . request.

What is static scope in PHP?

The final type of variable scoping that I discuss is known as static. In contrast to the variables declared as function parameters, which are destroyed on the function's exit, a static variable will not lose its value when the function exits and will still hold that value should the function be called again.

What is local variable in PHP?

Local variables are those variables that are declared inside the function of a Php program and have their scope inside that function only. Local variables have no scope outside the function (variable cannot be referenced outside the function), so cannot be used outside its scope in the program.


1 Answers

$_REQUEST["username"] = "Tom";

Reference : http://php.net/manual/en/reserved.variables.request.php

like image 78
Tarik Avatar answered Oct 14 '22 06:10

Tarik