CodeIgniter Forums
CodeIgniter 4 - $ sign is not accepted in placeholder - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: CodeIgniter 4 - $ sign is not accepted in placeholder (/showthread.php?tid=80003)



CodeIgniter 4 - $ sign is not accepted in placeholder - c4nn - 08-31-2021

Hi everyone, I have a problem. I have following in codeigniter 4

PHP Code:
<?php 
namespace App\Controllers\Backend;

use 
App\Controllers\BaseController;
use 
App\Models\PullData;


class 
Datass extends BaseController
{

public  function edit($id)
{



$pullData = new PullData();
$data['pullData'] = $pullData->find($id);
return 
view('backend/edit'$data);
}






PHP Code:
$routes->group('admin', function($routes){
    $routes->match(['get','post'],'login''Backend/AdminAuth::login');
    $routes->match(['get','post'],'signup''Backend/AdminAuth::signup');
    $routes->get('dashboard''Backend/Dashboard::index');
    $routes->get('logout''Backend/AdminAuth::logout');
    $routes->group('dashboard', function($routes){
        $routes->match(['get','post'],'profile''Backend/AdminAuth::profile');
        $routes->match(['get''post'], 'datas''Backend/Datass::index');
        $routes->match(['get''post'], 'createdata''Backend/Datass::create');
        $routes->match(['get''post'], 'save-data''Backend/Datass::savedata');
        $routes->get('edit/(:any)''Backend/Datass::edit/$1');    <----
    
    
});
}); 
Code:
http://localhost/admin/dashboard/edit/1
gives me 404 error. However if I remove $ sign as follow it works
PHP Code:
$routes->get('edit/(:any)''Backend/Datass::edit/$1'); 
But this time it's only showing the values of 1.


RE: CodeIgniter 4 - $ sign is not accepted in placeholder - InsiteFX - 09-01-2021

Your missing the route group function closing bracket }.


RE: CodeIgniter 4 - $ sign is not accepted in placeholder - iRedds - 09-01-2021

Use backslash in class namespace
Backend/Datass:: <- bad
Backend\Datass:: <- good