CodeIgniter Forums
New controller Namespace declaration statement has to be the very first statement or - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: New controller Namespace declaration statement has to be the very first statement or (/showthread.php?tid=81750)



New controller Namespace declaration statement has to be the very first statement or - karimm - 04-22-2022

Hi,

When i create a new controler with vs code and xampp, i have the error "ErrorException #64 Namespace declaration statement has to be the very first statement or after any declare call in the script" line: 3
PHP Code:
<?php

namespace App\Controllers//line 3


class Events extends BaseController
{
    public function index()
    {

    }

Thanks


RE: New controller Namespace declaration statement has to be the very first statement or - InsiteFX - 04-24-2022

Not sure why vs code would be throwing that error, I use phpStorm and have never gotten that error.

try deleting the Controller and recreating it.


RE: New controller Namespace declaration statement has to be the very first statement or - iRedds - 04-24-2022

space or BOM


RE: New controller Namespace declaration statement has to be the very first statement or - JustJohnQ - 04-24-2022

I created the controller without any problems in VS Code using Wamp server 3.2.7.


RE: New controller Namespace declaration statement has to be the very first statement or - ikesela - 04-24-2022

remove whitespace before <?php


RE: New controller Namespace declaration statement has to be the very first statement or - karimm - 04-24-2022

(04-24-2022, 02:07 AM)iRedds Wrote: space or BOM

Thansk!