This code produces the correct $idtype variable null:
public function showUserAction($id = null)
{
var_dump($id);
}
, while the following code gives a variable of $idtype string:string(4) "null"
public function showUserAction($id = null)
{
var_dump($id);
}
routing.xml
<route id="acme_user_show" pattern="/show/{id}">
<default key="_controller">AcmeUserBundle:User:show</default>
<default key="id">null</default>
<requirement key="id">\d+</requirement>
</route>
I would suggest that 2 would give similar results, is that normal? How to give default null value in xml?
- I visit a path
/showUserto check if the value of the variable $idis null. - I also tried
<default key="id" />instead of <default key="id">null</default>=> without success
source
share