Michdd Posted August 12, 2009 Share Posted August 12, 2009 I'm using eval() in an image handling class that I'm writing and I seem to be having a problem with it.. When I do this it doesn't create a valid image resource: $this->image = eval("imagecreatefrom" . $this->ext . "('" . $this->file . "');"); Where $this->ext is the mime type (png, gif, jpeg etc..) and $this->file is the filename of the image. However when testing this works: $this->image = imagecreatefromgif($this->file); This doesn't seem to work either: eval("image" . $this->ext . "('" . $this->image . "');"); But in testing this does: imagegif($this->image); I'm not sure why, am I doing something in eval incorrectly? Link to comment https://forums.phpfreaks.com/topic/169931-solved-eval-help/ Share on other sites More sharing options...
Daniel0 Posted August 12, 2009 Share Posted August 12, 2009 Try: $funcName = 'imagecreatefrom' . $this->ext; $funcName($this->file); Link to comment https://forums.phpfreaks.com/topic/169931-solved-eval-help/#findComment-896438 Share on other sites More sharing options...
Michdd Posted August 12, 2009 Author Share Posted August 12, 2009 Try: $funcName = 'imagecreatefrom' . $this->ext; $funcName($this->file); Wow, I never knew that was possible. Thanks a lot! It worked perfectly. Link to comment https://forums.phpfreaks.com/topic/169931-solved-eval-help/#findComment-896442 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.