1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP file in image source html code <img src="url.php"> etc.

Discussion in 'PHP' started by MediaHustler, Jan 26, 2006.

  1. #1
    Can't find it on google. What I want is a php file to work in <img src="url.php">

    And it show up in its intirety.
    SEMrush

    I'm wanting to use it for google ads basically saying url.php has the google ad code in it, and when the image source html code is applied... It appears.


    Thank you.
     
    MediaHustler, Jan 26, 2006 IP
    SEMrush
  2. fsmedia

    fsmedia Prominent Member

    Messages:
    5,165
    Likes Received:
    262
    Best Answers:
    0
    Trophy Points:
    390
    #2
    You need to use the header() function in the first line of the PHP file. You can set the "header" of the file appear as any format (ie a CSS file, a PNG file, a JPG, etc etc). Then you can do what you need to in the actual php to make the image show up as you want it to.

    Further Reading: http://us3.php.net/image
     
    fsmedia, Jan 26, 2006 IP
  3. stuw

    stuw Peon

    Messages:
    702
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #3
    have i missed something here? Why wouldn't you just do
    <?php include('url.php') ?>
     
    stuw, Jan 26, 2006 IP
  4. fsmedia

    fsmedia Prominent Member

    Messages:
    5,165
    Likes Received:
    262
    Best Answers:
    0
    Trophy Points:
    390
    #4
    Because you can't source a php file and then just use include('img.jpg');, if you want to source a php file, you need to header it first so that it appears like an image (to the browser).
     
    fsmedia, Jan 26, 2006 IP
  5. stuw

    stuw Peon

    Messages:
    702
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes, if he wants to include an image - but I thought google ad code was javascript - that's the bit I don't understand
     
    stuw, Jan 26, 2006 IP
  6. fsmedia

    fsmedia Prominent Member

    Messages:
    5,165
    Likes Received:
    262
    Best Answers:
    0
    Trophy Points:
    390
    #6
    Ah yes, you are right. I must have missed that. There's no way to include Javascript in an img that is headered as an image. You will want to use a PHP include rather, and include a page that displays it normally. What you're trying to do is not possible and if it were possible, it would be against the AdSense TOS.
     
    fsmedia, Jan 26, 2006 IP
  7. MediaHustler

    MediaHustler Well-Known Member

    Messages:
    1,860
    Likes Received:
    46
    Best Answers:
    0
    Trophy Points:
    120
    #7
    I've seen it done before. :cry:
     
    MediaHustler, Jan 26, 2006 IP
  8. AStaupe

    AStaupe Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I've never seen <img src="url.php"> but I have seen <img href="url.php"> I'm not sure exactly how it works but it seems like it runs part of the "url.php" file. Hopefully this will help you.
     
    AStaupe, Jan 27, 2006 IP
  9. X606X

    X606X Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    if the php file is blank and just a generated image could you not just add a fake varible to trick the browser eg image.php?load=.jpg
     
    X606X, Jan 27, 2006 IP
  10. janjalani

    janjalani Active Member

    Messages:
    238
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    58
    #10
    What if I have two images on my url.php and I want to load it as <img src="url.php">, can I do that?
     
    janjalani, Jan 28, 2006 IP
  11. X606X

    X606X Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Both images? Erm, I would not know how. Maybe making the php file do the image tag and just include the php?
     
    X606X, Jan 28, 2006 IP
  12. wwm

    wwm Peon

    Messages:
    308
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #12
    i dont understand do u want to INCLUDE adsense code in ur site

    or show an PHP GENERATED IMAGE??
     
    wwm, Jan 28, 2006 IP
  13. janjalani

    janjalani Active Member

    Messages:
    238
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    58
    #13
    I have two images coming from 2 <image src="xxx.jpg> tags, but I just want to combine them to <image src="url.php">
     
    janjalani, Jan 28, 2006 IP
  14. whisucul

    whisucul Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    That is so nice collection.Well after finding your this comment there is no need for any book reading search of last few years.I like your idea for distributing the books by years.
     
    whisucul, Dec 16, 2009 IP
  15. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #15
    hi there ... your answer is yes!

    we can use php files to display image, just put header('content-type: image/png'); in your top php or before output :)

    then u have image with php extension :D

    regards

    note: pls change header type image to suit with ur application
     
    ghprod, Dec 18, 2009 IP
  16. Arttu

    Arttu Member

    Messages:
    139
    Likes Received:
    2
    Best Answers:
    8
    Trophy Points:
    40
    #16
    How about iframe?
    <iframe src="url.php"></iframe>
     
    Arttu, Dec 18, 2009 IP
  17. AustinQPT

    AustinQPT Member

    Messages:
    75
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #17
    I recommend looking into php's GDLib.
     
    AustinQPT, Dec 18, 2009 IP
  18. Ahmed3335

    Ahmed3335 Guest

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #18
    use header function...Hope it will work...
     
    Ahmed3335, Feb 19, 2012 IP