I have this easy PHP script:
<?php
return array (
'information' => array (
'key' => 'value'
);
);
?>
When I call this script in the browser, there is a clear HTML page. This is quite normal.
Is there any way to catch this array and read it in the browser?
For example with console(firebug) or kali linux etc?
The return statement is entirely internal to PHP, it is not visible to any other process. In the context you've used it, the argument is simply ignored. There would be no way for anything other than PHP to understand something like an array anyway, as that is a data structure unique to the PHP runtime engine.
The main "result" of a PHP script (in a web server context) is its output, which is passed via the web server to the browser at the other end of the connection. You can also influence the HTTP headers the web server will include, using the header()
function.
To output data for use elsewhere, you need to come up with a string representation. The easiest is probably to use echo json_encode($value);
No, return doesn't send the data to the client. If you do a return statement in global scope you end the script. You can also read more about return in the manual.
And a quote from there:
If called from the global scope, then execution of the current script file is ended. If the current script file was included or required, then control is passed back to the calling file.