Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Jak sprawdzić czy argument funkcji jest podany?
pawel.ad
post
Post #1





Grupa: Zarejestrowani
Postów: 60
Pomógł: 0
Dołączył: 8.03.2010
Skąd: Zielona Góra

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


Witam!

Nie wiem jak sprawdzić czy argument X w funkcji jest podany.
Zwykłe isset() wywala błąd:

Fatal error: Can't use function return value in write context in /var/www/strona/functions.php on line 8

Kod funkcji:
  1. function val_prc() {
  2.  
  3. func_get_arg(0) == $val1;
  4. func_get_arg(1) == $val2;
  5.  
  6. if(isset(func_get_arg(2))) {
  7. func_get_arg(2) == $val3;
  8. }
  9. else {
  10. $val1 == $val3;
  11. }
  12. if(isset(func_get_arg(3))) {
  13. func_get_arg(3) == $val4;
  14. }
  15. else {
  16. $val2 == $val4;
  17. }
  18.  
  19.  
  20. if($val1 > 0) {
  21. return $val1." - ".$val2." (".round($val3/$val4*100, 1)."%)";
  22. }
  23. else return "<p class=\"center\">-</p>";
  24.  
  25. };


Ten post edytował pawel.ad 1.04.2010, 15:33:33
Go to the top of the page
+Quote Post

Posty w temacie


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: 20.08.2025 - 00:03