phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


PHP Image: Embed Your Image to PHP Line Codes

Tag: image, gd   Category: PHP Classes
post: 01 Jan 2008 read: 1,183


PHP Image Tutorial: Usually, we put image in a directory. Then, we call by using tag <img src="/path/to/image">. We can see clearly location and name of the image file. In this post, We will talk how to hide image and emmbed to our php line code. So, we will not put image file to a directory. It is nice idea!

We need class named "img2php". You can download at phpclasses.org/img2php. After download, follow this steps:

  1. Extract zip file to specific directory, for example, www/test/img2php like following sceen.
    embed image to php code - prepare class file
  2. Create folder named "images" within www/test/img2php. Put some images file.
    embed image to php code - prepare images
  3. Create a file name "test.php" within www/test/img2php.
  4. Enter following code
    
     <?
     require_once("img2php.class.php");
     
     $t = new img2php;
     $t ->generate("images");
     ?>
    
  5. Point your browser to http://localhost/test/img2php/test.php. You will get like following screen:
    embed image to php code - code
  6. Create file named "test.class.php" within www/test/img2php. Enter code that you got from browser. Just copy all and paste.
  7. Last, we create page that load the image. Create a file named "test.show.php" within www/test/img2php. Enter following code:
    
     <?
     include "test.class.php";
     
     $img  = new gonximage();
     $name = "action_forward_gif";
     $img  ->getImage($name);
     
     ?>
    

Now, point your browser to http://localhost/test/img2php/test.show.php.

Happy New Year!



| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting