tags:

views:

56

answers:

4

How can you see the type of variables: POST, GET, cookie, other?, after running var_dump($_REQUEST)?

I run the following

 start_session();
 --- other code here --
 var_dump($_REQUEST);

It gives me

array(3) { ["login"]=> string(0) "" ["sid"]=> string(32) "b3408f5ff09bfc10c5b8fdeea5093d3e" ["PHPSESSID"]=> string(32) "b3408f5ff09bfc10c5b8fdeea5093d3e" }

+1  A: 

I'm not sure I understand your question. Did you try:

var_dump($_POST);
var_dump($_COOKIE);
var_dump($_SESSION);

etc?

$_REQUEST is a different variable than $_POST and the others. Was there something specific you are trying to see?

zombat
Thank you for your answer! - I asked the question because I am not sure about the type of cookie my session in is stored, either locally or externally.
Masi
A: 

To look at the specific array you can do this

echo "<pre>";
print_r($_GET);
print_r($_POST);
echo "</pre>";

The pre tag is just to make it look nice. To access each of those do this.

$var = $_GET['paramName'];

Likewise with the other Super Arrays.

jW
+1  A: 

If by "the type of variables: POST, GET, cookie, other?" you mean "are the variables in $_REQUEST" coming from $_GET, $_POST, $_COOKIE, or environnement", I don't think there is a way : you will have to check inside those yourself...

And, btw, you'll have to do that taking into account the order that PHP uses those to populate $_REQUEST ; it is configured by this directive : http://php.net/manual/en/ini.core.php#ini.variables-order

But, still, why not work with $_GET, $_POST and others directly ?
Would probably be much more easier...

Pascal MARTIN
+1  A: 

A neat little function to prettily print out a variable's contents:

function debugVar($var)
{
    echo '<pre>';
    print_r($var);
    echo '</pre>';
}

debugVar($_GET);
debugVar($_POST);
debugVar($blah);

On that note, do you literally mean, for example, what 'type' is $_GET? If so then the answer is array.

karim79