• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use $request->uri->getSegment() inside view?

#1
Exclamation 
I'm trying to use `$ request-> uri-> getSegment (1)` in the view but I get an error saying "Undefined variable: request", what should I do to display a given segment in the view?
Reply

#2
(06-20-2020, 11:02 AM)0x0undefined Wrote: I'm trying to use `$ request-> uri-> getSegment (1)` in the view but I get an error saying "Undefined variable: request", what should I do to display a given segment in the view?

I use this, in Model:
PHP Code:
$request = \Config\Services::request();
        $uri $request->uri;
        $id $uri->getSegment(3); 
Reply

#3
(06-20-2020, 11:02 AM)0x0undefined Wrote: I'm trying to use `$ request-> uri-> getSegment (1)` in the view but I get an error saying "Undefined variable: request", what should I do to display a given segment in the view?
Did you solve the problem?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.