Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Pobieranie zmiennej z innej funkcji?
JamalBIG
post
Post #1





Grupa: Zarejestrowani
Postów: 496
Pomógł: 1
Dołączył: 16.01.2008
Skąd: Świnoujście

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


Witam

W jaki sposob zrobic aby funkcja jakasfunkcja() pobierala zmienna $nazwa ktora jest nad nia?

$nazwa = "nazwa";
function jakasfunkcja()
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
JamalBIG
post
Post #2





Grupa: Zarejestrowani
Postów: 496
Pomógł: 1
Dołączył: 16.01.2008
Skąd: Świnoujście

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


Wszystko jest ok bo fotka mi sie dobrze uploaduje, katalog sie tworzy tylko ta nieszczesna miniaturka nie chce sie 'zrobic'.... Calkowicie nie wiem dlaczego....
W tej postaci dziala, w tej powyzej juz nie...

  1. <?php
  2.  
  3. function makeIcons_MergeCenter($in, $out, $max_width, $max_height, $jakosc = 80) //mała poprawka 
  4. {
  5.  
  6. $typ = img_typ($in);
  7.  
  8. if ($typ == ".jpg") {$img_src = imagecreatefromjpeg($in);}
  9. elseif($typ == ".gif") {$img_src = imagecreatefromgif($in); }
  10. elseif($typ == ".png") {$img_src = imagecreatefrompng($in); }
  11.  
  12. $x = imagesx($img_src);
  13. $y = imagesy($img_src);
  14.  
  15. if($x > $y) 
  16. {
  17. $xr = ($x > $max_width)$max_width/$x : 1;
  18. $yr = $xr;
  19. }
  20. else 
  21. {
  22. $yr = ($y > $max_height)$max_height/$y : 1;
  23. $xr = $yr;
  24. }
  25.  
  26. $new_x = $x*$xr;
  27. $new_y = $y*$yr;
  28.  
  29. $new_img = imagecreatetruecolOR($new_x, $new_y);
  30. $background = imagecolORallocate($new_img, 255, 255, 255);
  31.  
  32. imagefill($new_img, 0, 0, $background);
  33. imagecopyresampled($new_img, $img_src, 0, 0, 0, 0, $new_x, $new_y, $x, $y);
  34.  
  35. $typ = img_typ($out);
  36.  
  37. if ($typ == ".jpg") {imagejpeg($new_img, $out, $jakosc);}
  38. elseif($typ == ".png") { imagepng($new_img, $out, $jakosc);}
  39. elseif($typ == ".gif") { imagegif($new_img, $out);  }
  40. }
  41.  
  42. function img_typ($name) 
  43. {
  44. $name = strtolower(substr($name, -4, 4));
  45.  
  46. if($name == '.jpg' OR $name == 'jpeg') 
  47. {
  48. return ".jpg";
  49. }
  50. elseif($name == '.gif') 
  51. {
  52. return ".gif";
  53. }
  54. elseif($name == '.png')
  55. {
  56. return ".png";
  57. }
  58. }
  59.  
  60. makeIcons_MergeCenter('test.jpg', 'nazwa.jpg', 200, 200);
  61. ?>


Ten post edytował JamalBIG 24.01.2008, 22:10:13
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: 11.10.2025 - 10:38