Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
NekoGD ~ The GD library for easier PHPGD implementation.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Markshall" data-source="post: 221522" data-attributes="member: 1872"><p>I can't help but think your config function could've been simplified a lot more.</p><p> </p><p>This is what you have:</p><p>[PHP]public function config($type, $height = "0", $width = "0") {</p><p> $this->height = $height;</p><p> $this->width = $width;</p><p> </p><p> switch( $type ) {</p><p> case "png":</p><p> $this->mime = 'png';</p><p> return header('Content-Type: image/png');</p><p> break;</p><p> case "gif":</p><p> $this->mime = 'gif';</p><p> return header('Content-Type: image/gif');</p><p> break;</p><p> case "jpeg":</p><p> $this->mime = 'jpeg';</p><p> return header('Content-Type: image/jpeg');</p><p> break;</p><p> }</p><p>}[/PHP]</p><p> </p><p>..and this is what you could have:</p><p>[PHP]public function config($type, $height = 0, $width = 0) {</p><p> $this->height = $height;</p><p> $this->width = $width;</p><p> </p><p> if (in_array(strtolower($type), array("png","gif","jpeg"))) {</p><p> $this->mime = strtolower($type);</p><p> return header('Content-type: image/' . strtolower($type));</p><p> }</p><p>}[/PHP]</p><p> </p><p>But yeah, pretty cool, nice work.</p></blockquote><p></p>
[QUOTE="Markshall, post: 221522, member: 1872"] I can't help but think your config function could've been simplified a lot more. This is what you have: [PHP]public function config($type, $height = "0", $width = "0") { $this->height = $height; $this->width = $width; switch( $type ) { case "png": $this->mime = 'png'; return header('Content-Type: image/png'); break; case "gif": $this->mime = 'gif'; return header('Content-Type: image/gif'); break; case "jpeg": $this->mime = 'jpeg'; return header('Content-Type: image/jpeg'); break; } }[/PHP] ..and this is what you could have: [PHP]public function config($type, $height = 0, $width = 0) { $this->height = $height; $this->width = $width; if (in_array(strtolower($type), array("png","gif","jpeg"))) { $this->mime = strtolower($type); return header('Content-type: image/' . strtolower($type)); } }[/PHP] But yeah, pretty cool, nice work. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
NekoGD ~ The GD library for easier PHPGD implementation.
Top