Welcome Guest, Not a member yet? Register   Sign In
Librarie File & SplFileInfo Namespace Error
#1

Hi,
I am trying to read a CSV file with the Class 'File' but ran in some errors.
PHP Code:
$file "test.csv";
$objFileCsv = new \CodeIgniter\Files\File($file);
echo 
$objFileCsv->getMTime();
$splFileCsv $objFileCsv->openFile('r');
 
$splFileCsv->setFlags(SplFileObject::READ_CSV); 
This i tryed in a helper without namespace and there is no problem. But in a Controller there is a error.
Quote:Class "App\Controllers\SplFileObject" not found

I didn't get it. I know its because the Namespace but SplFileInfo is a PHP build in Class and the Scope should be global or?

I also try

PHP Code:
namespace App\Controllers;
use 
SplFileInfo

What i am missing?
Reply
#2

Use  \SplFileObject
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply
#3

(10-05-2024, 11:40 AM)ozornick Wrote: Use  \SplFileObject

Thank you. Problem solved Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB