Jump to content

Explain:"$fieldname = $_REQUEST['fieldname']"


dogbot

Recommended Posts

NEWBIE ALERT:

New to Programming

Newer to PHP

Bad at formulating coherent questions.....so here it goes....

 

Could someone explain

$fieldname = $_REQUEST['fieldname']

 

I understand "$_REQUEST An associative array that by default contains the contents of $_GET, $_POST and $_COOKIE"

 

I also understand you call the member of an array like so: 

<?php
$arr = array("foo" => "bar", 12 => true);

echo $arr["foo"]; // bar
echo $arr[12];    // 1
?>

 

So I would expect that if someone wants to use something from the $_REQUEST Array they would use:

$fieldname = $_REQUEST['$_GET']

So I do not understand why "$fieldname" is inside the brackets.I suspect they might be setting this up to use $fieldname instead of $_REQUEST maybe...but why, that would be redundant? so I suspect I suspect wrong....

Link to comment
Share on other sites

$_REQUEST is an alternative to $_GET, $_POST and $_COOKIE, it doesn't contain $_GET, $_POST and $_COOKIE as keys, but rather the data contained within $_GET, $_POST and $_COOKIE merged into a new array called $_REQUEST.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.