|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-01-02 19:36 UTC] ed dot swartz at sandypondconsulting dot com
Under certain conditions form variables are not defined. When I access a form variable by printing it out using print or print_r( get_defined_vars() ), the form variable is available and has the correct value as expected. However, when I do not print the variable and use the form variable in a foreach construct the variable is not defined.
* register_globals is On according to phpinfo();
* I'm using session variables
* I'm using ob_start() to discard unwanted output.
* I did a standard/default installation.
I've tried simplifying the scripts to narrow down where or what is causing the problem but all my simplier scripts work fine. The following are excerpts from the original longer and more complex scripts.
// The Form page
// FileNameX strings were simplied from "c:\inetpub\wwwroot\ProjectName\Project.php"
<form action='Action.php' method='get'>
<input type='hidden' name='FormIncludes[]' value='FileName1'>
<input type='hidden' name='FormIncludes[]' value='FileName2'>
<input type='hidden' name='FormIncludes[]' value='FileName3'>
<input type='hidden' name='FormIncludes[]' value='FileName4'>
<table cols=2 width='400'>
.... HTML code omitted...
</table>
</form>
// Action.php
<?php
// These 2 lines have been inserted into the script for debug purposes.
// If left in as-is the variables are defined and print OK, if I comment out these 2 lines parser complains
// at the foreach loop that $FormIncludes is undefined.
print_r( get_defined_vars() );
print( $FormIncludes );
ob_start();
foreach( $FormIncludes as $FileName )
{
include_once( $FileName );
}
session_start();
global $Form;
$Form->PageProcess( $Submit );
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 18 00:00:01 2025 UTC |
After some debugging this appears to be related to arrays. I changed the FormIncludes[] definition on the Form page to FormInclude0, FormInclude1, FormInclude2, etc. On the action page I looped through each of the form variables $i = 0; while( 1 ) { $Variable = "FormInclude" . $i; ...use $$Variable... } This works.