Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Codeigniter skrócenie kodu php
--armind--
post
Post #1





Goście







Witajcie.

Zwracam się do was z pytaniem, czy da się to zapisać w jednej funkcji ? zeby linki wyglądały tak:

index.php/regards/utwor/on
index.php/regards/music/on

index.php/regards/utwor/off
index.php/regards/music/off


  1. public function onpozdro()
  2. {
  3. $this->Regards_model->offRegards();
  4. redirect('regards/index');
  5. }
  6.  
  7. public function offpozdro()
  8. {
  9. $this->Regards_model->offRegards();
  10. redirect('regards/index');
  11. }
  12.  
  13. public function onmusic()
  14. {
  15. $this->Regards_model->offMusic();
  16. redirect('regards/index');
  17. }
  18.  
  19. public function offMusic()
  20. {
  21. $this->Regards_model->offMusic();
  22. redirect('regards/index');
  23. }


Dziekuje za pomoc wink.gif
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
lukasz1985
post
Post #2





Grupa: Zarejestrowani
Postów: 205
Pomógł: 43
Dołączył: 5.03.2012

Ostrzeżenie: (0%)
-----


Z tego co widać - według urli ktore wywołujesz, według standardowego routingu kontrolerem będzie "regards" , akcją "utwor" a parametrem "on" lub "off" analogicznie przy akcji "muzyka"

Więc coś takiego powinno działać:
  1. public function utwor($cozrobic)
  2.  
  3. {
  4. if($cozrobic == "on") {
  5. // kod
  6. } else {
  7. // kod
  8. }
  9.  
  10. }
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 14:46