Issue using RecursiveIteratorIterator in a controller |
I am attempting to call php's RecursiveIteratorIterator through a function in my controller class and I get the debugger message, "Class 'App\Controllers\RecursiveIteratorIterator' not found." My controller operates fine without this, although I would like to have the option to use it. Here is my code. Why does it think I am trying to call a controller and how can I remedy the error? Thank you in advance for your consideration.
PHP Code: $newDataIterator = new RecursiveIteratorIterator(
It's a namespace issue. Within your controller, you're in the namespace App\Controllers. The RecursiveIteratorIterator is NOT in that namespace, so you must prefix it with a backslash, or add it as a use statement at the top of the file. That allows PHP to know to look for it in the root namespace, not in the current namespace (App\Controllers).
PHP Code: $newDataIterator = new \RecursiveIteratorIterator( or PHP Code: <?php namespace App\Controllers;
|
Welcome Guest, Not a member yet? Register Sign In |