Round-a-bout page loading
Posted: Thu Aug 31, 2006 6:32 pm
i'm having some trouble and was wondering if anyone could help. here's some sudo code to describe what i'm doing. i'm trying to figure out why i only get the first $_GET parameter from myfile.php. (MakeRequest() is a simple ajax function like you find all over the web).
index.php:
getfile.php:
myfile.php:
output (should be 2 params, missing age):
index.php:
Code: Select all
<script type="text/javascript">
callback = function( response ) { document.getElementByID( "someDiv" ).innerHTML = response; };
MakeRequest( "getfile.php?file=thefile.php?name=jim&age=35", callback );
</script>Code: Select all
$text = file_get_contents( $_GET[ 'file' ] );
// Evaluate each php block
while( ( $blockStart = strpos( $text, "<?php" ) ) !== false )
{
$blockEnd = strpos( $text, "?>", $blockStart ) + 1;
if( $blockEnd !== false )
{
$evalText = substr( $text, $blockStart + 5, ( $blockEnd - $blockStart ) - 6 );
ob_start();
eval( $evalText );
$newText = ob_get_contents();
ob_end_clean();
$text = substr_replace( $text, $newText, $blockStart, $blockEnd - $blockStart + 1 );
}
else
{
$text = "Missing closing element for php block";
break;
}
}
echo( $text );Code: Select all
echo( count( $_GET ) . "<br />" );
echo( $_GET[ 'name' ] . "<br />" );
echo( $_GET[ 'age' ] . "<br />" );Code: Select all
1
jim