I have the following PHP script:
<?php
function dump_extracted_post() {
extract($_POST);
var_dump(get_defined_vars());
}
dump_extracted_post();
?>
To this script, I post a form containing some data, and it produces the following (unexpected) result:
Array(0) {
}
Why do I not see the the posted data?
Is there something I've missed in my understanding of extract() or get_defined_vars()? Is there some sort of security setting that might be interfering with extracting from $_POST ?
I am aware of the frowned upon nature of extract, so perhaps it's a security issue, but scanning the php docs doesn't seem to mention any such issue. I want to use this to do some simple templating.
If I change the script to:
<?php
function dump_extracted_post() {
var_dump($_POST);
}
dump_extracted_post();
?>
I see the posted data as expected (so yes, I am definately posting data).
Likewise, if I change the script to:
<?php
function dump_extracted_post() {
$a = 'moocows';
var_dump(get_defined_vars());
}
dump_extracted_post();
?>
I see the expected output:
array(1) {
["a"]=>
string(7) "moocows"
}