PHP Classes

Routes add variable

Recommend this page to a friend!

      Simple Framework  >  All threads  >  Routes add variable  >  (Un) Subscribe thread alerts  
Subject:Routes add variable
Summary:i add variable to router and show only $1
Messages:2
Author:Adrian
Date:2014-10-30 18:50:54
 

  1. Routes add variable   Reply   Report abuse  
Picture of Adrian Adrian - 2014-10-30 18:50:54
Hi,

in your movie you show how we can add variables to route (https://www.youtube.com/watch?v=iEpIVOAeaHw).

In routes.php i add:
$this->get('profil/(:str)', 'demo/profil/$1');

and in controller demo.php i add:
public function profil($id) {
print $id;
}

and when i try check it (localhost/profil/dsdas) i see:
$1

whats wrong?

  2. Re: Routes add variable   Reply   Report abuse  
Picture of Adrian Adrian - 2014-10-30 19:06:14 - In reply to message 1 from Adrian
I found an error.

in system/Router.php (line 116) is:
for($i=2;$i<count($this->_tmp);$i++){

but should be:
for($i=1;$i<count($this->_tmp);$i++){