php - Correct regex for param after an optional forward slash -


what correct way on php, phalcon framework on how optionally escape forward slash "/" has optional parameter @ end.

i want achieve:

http://example.com/transactions http://example.com/transactions/ http://example.com/transactions/1 http://example.com/transactions/2 

my regex:

working, without params :(

transactions[/]{0,1} 

not working, on server logs, it's adding "transactions/2" if url not have it.

transactions[/]{0,1}{param} 

working, explicitly instruct have param @ end. how can have optional "/" forward slash.

transactions/{param} 

appreciate advise.

thanks

assuming have transactionscontroller indexaction(), try defining 2 routes explained :

<?php $router->add(     "/transactions/{param}",     array(         "controller" => "transactions",         "action"     => "index",     ) );  $router->add(     "/transactions",     array(         "controller" => "transactions",         "action"     => "index",     ) ); 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -