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
b_chmura
post
Post #2





Grupa: Zarejestrowani
Postów: 813
Pomógł: 34
Dołączył: 18.03.2007
Skąd: o stamtąd

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


swoją funkcje makeIcons_MergeCenter podmień na tą:

  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. ?>


i dodaj tą:
  1. <?php
  2. function img_typ($name) 
  3. {
  4. $name = strtolower(substr($name, -4, 4));
  5.  
  6. if($name == '.jpg' OR $name == 'jpeg') 
  7. {
  8. return ".jpg";
  9. }
  10. elseif($name == '.gif') 
  11. {
  12. return ".gif";
  13. }
  14. elseif($name == '.png')
  15. {
  16. return ".png";
  17. }
  18. }
  19. ?>


Edit:
Cytat
o boshe ...

~Neekea a Ty pisać po polsku

Ten post edytował b_chmura 24.01.2008, 20:56:05
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 13.10.2025 - 09:17