我使用Moodle set_config函数来设置配置,然后通过get_config检查,得到不同的结果。 为什么

$my_var = $_POST["myVar"];

$my_var contains an array named myVarInfoArray. I save it to db using set_config.

if ( isset($my_var["myVarInfoArray"]) ) {
        set_config('InfoArray', json_encode($my_var["myVarInfoArray"]), $plugin);
}

Then I check it with get_config:

echo '<br>';
print_r(  $my_var["myVarInfoArray"]  ); // PRINTS AS EXPECTED
echo '<br><br><br>';
print_r(    json_decode(  get_config('theme_testy', 'InfoArray')  )     ); //PROBLEM =(

The two print_r's output:

Array
(
    [0] => Array([image] => http://localhost/moodle/theme/testy/pix/images/1.jpg)
    [1] => Array([image] => http://localhost/moodle/theme/testy/pix/images/2.jpg)
    [2] => Array([image] => http://localhost/moodle/theme/testy/pix/images/3.jpg)
    [3] => Array([image] => http://localhost/moodle/theme/testy/pix/images/4.jpg)
)

Array
(
    [0] => stdClass Object ( [image] => http://localhost/moodle/theme/testy/pix/images/1.jpg )
    [1] => stdClass Object ( [image] => http://localhost/moodle/theme/testy/pix/images/5.jpg )
)
  1. So why this difference! It is very confusing because where does 5.jpg come from in the second print?

  2. I am also getting the following error when I submit the form, and no debugging messages on this middle page (which appears when redirecting) although the debugging is on:

    Error output, so disabling automatic redirect.

So can anyone point out what might be going wrong here? Any suggestions are welcome?