Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Funkcje zwracanie return
matti9410
post
Post #1





Grupa: Zarejestrowani
Postów: 70
Pomógł: 0
Dołączył: 10.07.2013

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


Witam,
Dla wielu z was jest to pewnie banalne..
Mam funkcje przykładowo dodawania zdj
  1. function upload_images_file($images_file) {
  2. $id = $_SESSION['user_id'];
  3. $BASE_DIR = $_SERVER['DOCUMENT_ROOT'];
  4. $location_images_file = "$BASE_DIR/admin/images/user$id";
  5. $name_file = $images_file['name'];
  6. $type_file = $images_file['type'];
  7. $tmp_name_file = $images_file['tmp_name'];
  8. $size_file = $images_file['size'];
  9. $max_size_file = 2000000;
  10.  
  11. $info = pathinfo($name_file);
  12. $enlargement = $info['extension'];
  13.  
  14. if(($type_file == "image/jpeg") || ($type_file == "image/jpg") || ($type_file == "image/png")){
  15. if($size_file < $max_size_file){
  16. if (!file_exists($location_images_file))
  17. {
  18. mkdir("$location_images_file", 0777);
  19. if(is_uploaded_file($tmp_name_file)) {
  20. move_uploaded_file($tmp_name_file, "$location_images_file/avatar.$enlargement");
  21. return true;
  22. }else{
  23. return false;
  24. }
  25. }else{
  26. if(is_uploaded_file($tmp_name_file)) {
  27. move_uploaded_file($tmp_name_file, "$location_images_file/avatar.$enlargement");
  28. return true;
  29. }else{
  30. return false;
  31. }
  32. }
  33. }else{
  34. return false;
  35. }
  36. }else{
  37. return false;
  38. }
  39.  
  40. };


mam tam wiele if'ów i chciałbym się was zapytać skąd mam wiedzieć w którym ifie mi funkcja zwaraca true a w którym false. Jest mi to potrzebne bo np. chciałbym wyświetlać na tego podstawie komunikat czy np obraz ma zły format czy rozmiar.

Ten post edytował matti9410 22.04.2017, 16:09:37
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: 19.08.2025 - 21:37