watcher
12-16-2006, 09:11 PM
Hi people,
simple question
How can i get the property values from an Object datatype in PHP?
situation: AS3.0 example
Using AS3.0 i am sending to PHP two variables inside an Object like this:
var var1:int = Math.floor( Math.random( ) * 100 );
var var2:String = "test string";
var test:Object = new Object();
test.var1 = var1;
test.var2 = var2;
var request:URLRequest = new URLRequest( "path_to_php_file" );
request.data = test;
request.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader( );
loader.addEventListener( Event.COMPLETE, handleResponse );
loader.load( request );
situation: PHP example
path_to_php_file points to PHP file called from flash, its content looks like this:
<?php
$glob = $GLOBALS['HTTP_RAW_POST_DATA'];
$fgc = file_get_contents("php://input");
echo "GLOBALS:__" . $glob .
"\nfile_get_contents:__" . $fgc .
"\nPOST:__" . $_POST;
?>
The result is traced in flash (function handleResponse ), and it traces:
GLOBALS:__
file_get_contents:__[object Object]
POST:__Array
i also tried.. (not working)
echo $fgc->var1 // returns empty string
echo $fgc['var1'] // returns left bracket --> [ (lol..)
echo $_POST[0] // returns empty string
my questions
1. GLOBALS: why does $GLOBALS['HTTP_RAW_POST_DATA'] return empty string?
2. file_get_contents: how can i trace values of properties var1 and var2 inside PHP?
3. POST: how can i trace values of that Array datatype inside PHP ?
You see, this is simple problem, and i am complete llama (http://en.wikipedia.org/wiki/Llama)with PHP :)
Thank You so much for Your time..
simple question
How can i get the property values from an Object datatype in PHP?
situation: AS3.0 example
Using AS3.0 i am sending to PHP two variables inside an Object like this:
var var1:int = Math.floor( Math.random( ) * 100 );
var var2:String = "test string";
var test:Object = new Object();
test.var1 = var1;
test.var2 = var2;
var request:URLRequest = new URLRequest( "path_to_php_file" );
request.data = test;
request.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader( );
loader.addEventListener( Event.COMPLETE, handleResponse );
loader.load( request );
situation: PHP example
path_to_php_file points to PHP file called from flash, its content looks like this:
<?php
$glob = $GLOBALS['HTTP_RAW_POST_DATA'];
$fgc = file_get_contents("php://input");
echo "GLOBALS:__" . $glob .
"\nfile_get_contents:__" . $fgc .
"\nPOST:__" . $_POST;
?>
The result is traced in flash (function handleResponse ), and it traces:
GLOBALS:__
file_get_contents:__[object Object]
POST:__Array
i also tried.. (not working)
echo $fgc->var1 // returns empty string
echo $fgc['var1'] // returns left bracket --> [ (lol..)
echo $_POST[0] // returns empty string
my questions
1. GLOBALS: why does $GLOBALS['HTTP_RAW_POST_DATA'] return empty string?
2. file_get_contents: how can i trace values of properties var1 and var2 inside PHP?
3. POST: how can i trace values of that Array datatype inside PHP ?
You see, this is simple problem, and i am complete llama (http://en.wikipedia.org/wiki/Llama)with PHP :)
Thank You so much for Your time..