Welcome Guest, Not a member yet? Register   Sign In
CI4- how to pass string with slash(/) to controller
#5

(02-14-2023, 05:39 PM)kenjis Wrote: In C4, you can't get parameter including /.

Code:
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -31,6 +31,8 @@ $routes->set404Override();
// route since we don't have to scan directories.
$routes->get('/', 'Home::index');

+$routes->get('iobrg/download/(:any)', 'Home::index/$1');
+
/*
  * --------------------------------------------------------------------
  * Additional Routing

Code:
--- a/app/Controllers/Home.php
+++ b/app/Controllers/Home.php
@@ -4,8 +4,8 @@ namespace App\Controllers;

class Home extends BaseController
{
-    public function index()
+    public function index(...$p)
    {
-        return view('welcome_message');
+        dd(implode('/', $p));
    }
}

http://localhost:8080/iobrg/download/056...P/XII/2022

You will see "056/SMB-PAP/XII/2022".
did'nt work

[Image: Screenshot-2023-02-15-080358.jpg]
Reply


Messages In This Thread
RE: CI4- how to pass string with slash(/) to controller - by randyshare - 02-14-2023, 06:05 PM



Theme © iAndrew 2016 - Forum software by © MyBB