debug and array

Hello!

I want to debug a script.
This script expects an array 'myParams'.

$ myParams = array (
   'foo' = 'aaa',
   'bla' = 123
);


Can I to
Run> Edit Configurations> Run / Debug Configurations> Arguments
use? params.jpg

Sincerely yours

Stephan Krauss

1 comment
Comment actions Permalink

You can't pass and array (or object) as a command line paramter. You can do something like this:

Configure your Arguments value to be this:

myParams[]=1 myParams[]=2 myParams[]=3 myParams[]=4

And then in the script do this:

if($argv)
parse_str(implode("&", array_slice($argv, 1)), $_GET);

print_r($_GET);


Results in this:

C:\PHP\php.exe C:\inetpub\Intranet_Local\test\test4.php myParams[]=1 myParams[]=2 myParams[]=3 myParams[]=4
Array
(
    [myParams] => Array
        (
            [0] => 1
            [1] => 2
            [2] => 3
            [3] => 4
        )
)

0

Please sign in to leave a comment.