Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
controllers [2016/01/05 19:40] luchothoma |
controllers [2016/12/30 18:42] (actual) |
||
---|---|---|---|
Línea 42: | Línea 42: | ||
public function youSaid($message) | public function youSaid($message) | ||
{ | { | ||
- | echo "You said: $message"; | + | echo "You said: ".$message; |
} | } | ||
} | } | ||
Línea 48: | Línea 48: | ||
Now if you visit /about/you/cool it will display "You said: cool". | Now if you visit /about/you/cool it will display "You said: cool". | ||
- | Now there is one problem with this. If you where to visit index.php/about/you then you would get a 404 error! This is because you can't just run youSaid(), it has a required argument! If you want people to still be able to visit the page, then you need to make your argument optional: | + | Now there is one problem with this. If you where to visit /about/you then you would get a 404 error! This is because you can't just run youSaid(), it has a required argument! If you want people to still be able to visit the page, then you need to make your argument optional: |
<code php> | <code php> | ||
- | public function bob($message = 'nothing at all') | + | public function youSaid($message = 'nothing at all') |
{ | { | ||
- | echo "You said: $message"; | + | echo "You said: ".$message; |
} | } | ||
</code> | </code> | ||
- | Now visiting /about/you will produce "You said: nothing at all", althoughthis if you visiting /about/bob/cool will still display"You said: cool". | + | Now visiting /about/you will produce "You said: nothing at all", althoughthis if you visiting /about/you/cool will still display"You said: cool". |
At this point you should try experimenting around with adding additional controllers, functions, and arguments and see what happens. | At this point you should try experimenting around with adding additional controllers, functions, and arguments and see what happens. | ||
Línea 76: | Línea 76: | ||
?> | ?> | ||
</code> | </code> | ||
+ | ---- | ||
+ | [[documentation|Go back to Documentation]] |