Multiple named regular expressions

61 views
Skip to first unread message

Joseph Carrington

unread,
Jul 27, 2010, 7:24:18 PM7/27/10
to GluePHP
Hello. I would like to use GluePHP in a controller/action/variable
sort of a way.

I want my url's to process like so:

http://www.example.com/CONTROLLER/ACTION/VARIABLE/

for a real world example:

http://www.example.com/user/view/joe/

How can I get each of these parts of the url as named regular
expressions?

Here's what I have so far:

$urls = array(
'/user(?P<action>/[a-zA-Z]*)(?P<user>/[a-zA-Z0-9]*)' =>
'controller_user'
);

but there are a number of problems with that. Mainly, it doesn't work.
Secondly, I have to use a preceding '/' in my switch cases like so:


switch($request['action'])

{
case '/login':


So I need to find a way to make the '/' only be searched for in there
is in fact stuff going on after it, but not add it to the variable.
Also, I just need to get it to work at all ;)

My ideal implementation:

function GET($request)
{
switch($request['action'])
{
case 'view':
echo 'viewing the profile of ' . $request['user'];
}
}

geekcube

unread,
Oct 12, 2012, 4:35:48 PM10/12/12
to glu...@googlegroups.com
did you ever notice there is no slash after 'user'?

 '/user(?P<action>/[a-zA-Z]*)(?P<user>/[a-zA-Z0-9]*)' => 
'controller_user' 

Reply all
Reply to author
Forward
0 new messages