Witam
W jaki sposob zrobic aby funkcja jakasfunkcja() pobierala zmienna $nazwa ktora jest nad nia?
$nazwa = "nazwa";
function jakasfunkcja()
<?php $nazwa = "wartość"; function jakas_funkcja(){ } ?>
<?php class C{ } function jakas_funkcja(){ } ?>
<?php function makeIcons_MergeCenter($in, $out, $max_width, $max_height, $jakosc = 80) //mała poprawka { $typ = img_typ($in); if ($typ == ".jpg") {$img_src = imagecreatefromjpeg($in);} elseif($typ == ".gif") {$img_src = imagecreatefromgif($in); } elseif($typ == ".png") {$img_src = imagecreatefrompng($in); } $x = imagesx($img_src); $y = imagesy($img_src); if($x > $y) { $xr = ($x > $max_width)? $max_width/$x : 1; $yr = $xr; } else { $yr = ($y > $max_height)? $max_height/$y : 1; $xr = $yr; } $new_x = $x*$xr; $new_y = $y*$yr; $new_img = imagecreatetruecolOR($new_x, $new_y); $background = imagecolORallocate($new_img, 255, 255, 255); imagefill($new_img, 0, 0, $background); imagecopyresampled($new_img, $img_src, 0, 0, 0, 0, $new_x, $new_y, $x, $y); $typ = img_typ($out); if ($typ == ".jpg") {imagejpeg($new_img, $out, $jakosc);} elseif($typ == ".png") { imagepng($new_img, $out, $jakosc);} elseif($typ == ".gif") { imagegif($new_img, $out); } } ?>
<?php function img_typ($name) { if($name == '.jpg' OR $name == 'jpeg') { return ".jpg"; } elseif($name == '.gif') { return ".gif"; } elseif($name == '.png') { return ".png"; } } ?>
<?php if ($cat == "c1") { $cat = "videos"; } else { $cat = "torrents"; } $file = $_FILES['my_file']['name']; $r = $r[0]; $filename = "downloads/$cat/$file"; } else { } } $pic = $_FILES['my_pic']['name']; $p = $r[0]; } } } function makeIcons_MergeCenter($in, $out, $max_width, $max_height, $jakosc = 80) //mała poprawka { $typ = img_typ($in); if ($typ == ".jpg") {$img_src = imagecreatefromjpeg($in);} elseif($typ == ".gif") {$img_src = imagecreatefromgif($in); } elseif($typ == ".png") {$img_src = imagecreatefrompng($in); } $x = imagesx($img_src); $y = imagesy($img_src); if($x > $y) { $xr = ($x > $max_width)? $max_width/$x : 1; $yr = $xr; } else { $yr = ($y > $max_height)? $max_height/$y : 1; $xr = $yr; } $new_x = $x*$xr; $new_y = $y*$yr; $new_img = imagecreatetruecolOR($new_x, $new_y); $background = imagecolORallocate($new_img, 255, 255, 255); imagefill($new_img, 0, 0, $background); imagecopyresampled($new_img, $img_src, 0, 0, 0, 0, $new_x, $new_y, $x, $y); $typ = img_typ($out); if ($typ == ".jpg") {imagejpeg($new_img, $out, $jakosc);} elseif($typ == ".png") { imagepng($new_img, $out, $jakosc);} elseif($typ == ".gif") { imagegif($new_img, $out); } } function img_typ($name) { if($name == '.jpg' OR $name == 'jpeg') { return ".jpg"; } elseif($name == '.gif') { return ".gif"; } elseif($name == '.png') { return ".png"; } } makeIcons_MergeCenter('downloads/$cat/$r/$file', 'downloads/$cat/$r/thumb.jpg', 200, 200); ?>
<?php function makeIcons_MergeCenter($in, $out, $max_width, $max_height, $jakosc = 80) //mała poprawka { $typ = img_typ($in); if ($typ == ".jpg") {$img_src = imagecreatefromjpeg($in);} elseif($typ == ".gif") {$img_src = imagecreatefromgif($in); } elseif($typ == ".png") {$img_src = imagecreatefrompng($in); } $x = imagesx($img_src); $y = imagesy($img_src); if($x > $y) { $xr = ($x > $max_width)? $max_width/$x : 1; $yr = $xr; } else { $yr = ($y > $max_height)? $max_height/$y : 1; $xr = $yr; } $new_x = $x*$xr; $new_y = $y*$yr; $new_img = imagecreatetruecolOR($new_x, $new_y); $background = imagecolORallocate($new_img, 255, 255, 255); imagefill($new_img, 0, 0, $background); imagecopyresampled($new_img, $img_src, 0, 0, 0, 0, $new_x, $new_y, $x, $y); $typ = img_typ($out); if ($typ == ".jpg") {imagejpeg($new_img, $out, $jakosc);} elseif($typ == ".png") { imagepng($new_img, $out, $jakosc);} elseif($typ == ".gif") { imagegif($new_img, $out); } } function img_typ($name) { if($name == '.jpg' OR $name == 'jpeg') { return ".jpg"; } elseif($name == '.gif') { return ".gif"; } elseif($name == '.png') { return ".png"; } } makeIcons_MergeCenter('test.jpg', 'nazwa.jpg', 200, 200); ?>
<?php function makeIcons_MergeCenter($in, $out, $max_width, $max_height, $jakosc = 80) { $typ = img_typ($in); /* if ($typ == ".jpg") {$img_src = imagecreatefromjpeg($in);} elseif($typ == ".gif") {$img_src = imagecreatefromgif($in); } elseif($typ == ".png") {$img_src = imagecreatefrompng($in); } */ $img_src = $in; $x = imagesx($img_src); $y = imagesy($img_src); if($x > $y) { $xr = ($x > $max_width)? $max_width/$x : 1; $yr = $xr; } else { $yr = ($y > $max_height)? $max_height/$y : 1; $xr = $yr; } $new_x = $x*$xr; $new_y = $y*$yr; $new_img = imagecreatetruecolOR($new_x, $new_y); $background = imagecolORallocate($new_img, 255, 255, 255); imagefill($new_img, 0, 0, $background); imagecopyresampled($new_img, $img_src, 0, 0, 0, 0, $new_x, $new_y, $x, $y); $typ = img_typ($out); if ($typ == ".jpg") {imagejpeg($new_img, $out, $jakosc);} elseif($typ == ".png") { imagepng($new_img, $out, $jakosc);} elseif($typ == ".gif") { imagegif($new_img, $out); } } ?>
<?php makeIcons_MergeCenter('downloads/$cat/$r/$file', 'downloads/$cat/$r/thumb.jpg', 200, 200); ?>
<?php makeIcons_MergeCenter("downloads/$cat/$r/$file", "downloads/$cat/$r/thumb.jpg", 200, 200); ?>