Open ghost opened 8 years ago
You need to specify that the outer $books variable is global. e.g.
[1] boris> global $books;
[2] boris> $books = ['aaa', 'bbb'];
// array(
// 0 => 'aaa',
// 1 => 'bbb'
// )
[3] boris> function serveBooks() {
[3] *> global $books;
[3] *> var_dump($books);
[3] *> }
[4] boris> serveBooks();
array(2) {
[0]=>
string(3) "aaa"
[1]=>
string(3) "bbb"
}
// NULL
Hello This is my code.