Jump to content

Recommended Posts

You can just return them like normal, can't you?

 

try this:

 

test-class.php:

<?php

class Test
{
function printVars() {
	foreach ($_GET as $key => $val) {
		print 'GET: [' . $key . '] ' . $val . '<br />';
	}
	foreach ($_POST as $key => $val) {
		print 'POST: [' . $key . '] ' . $val . '<br />';
	}
}
}

?>

 

 

test.php?some=vars&to=print:

<?php

include 'test-class.php';

$test = new Test();
$test->printVars();

?>

That code will produce errors. If there are no post values and only url params you will get a foreach error on the foreach($_POST) as not array will exist. Same other way around.

 

As Thorpe said if your form uses a POST method the values will be contained in the $_POST array and in the $_GET array if using the GET method.

To display the array after form submission use print_r();

 

// display submitted input
// using POST method
print_r($_POST);

 

You can then access the data as you would a normal array.

ahh okay, testing at work with errors disabled, didn't think about that. Well to be hoenst wasn't really supposed to be anything more than a simple demonstration that you can still access $_GET and $_POST in the same way..

 

Adam

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.