ajicles Posted July 18, 2010 Share Posted July 18, 2010 I have my script that was working before I added a function to error trap different file extensions and I got an error and I can't figure it out. And I was wondering how I could just add the watermark to the image and just save it. Thanks ~AJ <?php $filename = @$_GET['image']; $filename = 'images/'.$filename.''; $ext = end(explode('.', $filename)); $ext = strtolower($ext); function HEADER(&$ext){ if ($ext == 'png'){ header('Content-Type: image/png'); } elseif($ext == 'bmp'){ header('Content-Type: image/png'); } elseif($ext == 'jpeg'){ header('Content-Type: image/png'); } elseif($ext == 'jpg'){ header('Content-Type: image/png'); } elseif($ext == 'gif'){ header('Content-Type: image/png'); } else { echo 'I do not know that file extenstion '; } } function DEST(&$ext){ if ($ext == 'png'){ $dest = imagecreatefrompng($filename); } elseif($ext == 'bmp'){ $dest = imagecreatefrombmp($filename); } elseif($ext == 'jpeg'){ $dest = imagecreatefromjpeg($filename); } elseif($ext == 'jpg'){ $dest = imagecreatefromjpg($filename); } elseif($ext == 'gif'){ $dest = imagecreatefromgif($filename); } else { echo 'I do not know that file extenstion '; } } $watermark = 'watermark.gif'; DEST($ext); $src = imagecreatefromgif($watermark); list($width, $height, $type, $attr)=getimagesize($filename); $markwidth = 86; $markheight = 20; $opacity = 35; imagecopymerge($dest, $src, ($width-$markwidth)>>1, ($height-$markheight)>>1, 0, 0, $markwidth, $markheight, $opacity); header($IMG); imagegif($dest); imagedestroy($dest); imagedestroy($src); Link to comment https://forums.phpfreaks.com/topic/208117-cannot-redeclare-error/ Share on other sites More sharing options...
Mchl Posted July 18, 2010 Share Posted July 18, 2010 There already is header function in PHP. You can't override it. Link to comment https://forums.phpfreaks.com/topic/208117-cannot-redeclare-error/#findComment-1087890 Share on other sites More sharing options...
ajicles Posted July 18, 2010 Author Share Posted July 18, 2010 There already is header function in PHP. You can't override it. Thank you. I thought it won't over write if the name was upper case. Link to comment https://forums.phpfreaks.com/topic/208117-cannot-redeclare-error/#findComment-1087916 Share on other sites More sharing options...
Pikachu2000 Posted July 18, 2010 Share Posted July 18, 2010 Variables are case-sensitive, functions aren't, so you need a unique name for them. Link to comment https://forums.phpfreaks.com/topic/208117-cannot-redeclare-error/#findComment-1087919 Share on other sites More sharing options...
ajicles Posted July 19, 2010 Author Share Posted July 19, 2010 Variables are case-sensitive, functions aren't, so you need a unique name for them. ok, Thanks Link to comment https://forums.phpfreaks.com/topic/208117-cannot-redeclare-error/#findComment-1087923 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.