Results 1 to 4 of 4

Thread: Include statements in GD?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Posts
    29

    Include statements in GD?

    Trying to figure out how to use the include statement in a GD script.
    When I use the include statement on line 18 in the script below I get an error
    Parse error: syntax error, unexpected T_STRING in /home/bamastrm/public_html/script/exper/png_create.php on line 18

    Any ideas how to correct this? thanks

    PHP Code:
    <?php
    header
    ("Content-Type: image/jpeg");
    $im ImageCreateFromJpeg("template.jpg"); 

    $yellow ImageColorAllocate($im2552420);
    $black ImageColorAllocate($im000);


    $kbmx "51°";
    $start2_x 231;
    $start2_y 222;

    $kmgm "51°";
    $start_x 234;
    $start_y 226;


    Imagettftext($im250$start_x$start_y$black'impact.ttf'" include("temp.php") ");
    Imagettftext($im250$start2_x$start2_y$yellow'impact.ttf'"");


    Imagejpeg($im''100);
    ImageDestroy($im);
    ?>

  2. #2
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Include statements in GD?

    remove the quotes.

    PHP Code:
    Imagettftext($im250$start_x$start_y$black'impact.ttf', include("temp.php")); 

  3. #3
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Include statements in GD?

    what you're doing will not produce the expected results unless temp.php is made to correctly return a value.

    by default, include() will return true or false based on whether or not the file could be included; if you define a variable as a call to include() (which you are essentially doing by putting it in a parameter as a function call), its default behaviour would be to set that variable to either true or false. to do what you expect from this include, you need to make sure temp.php has a return statement, as if it were a function itself:

    PHP Code:
    temp.php:
    <?php

      $text 
    "My text goes here";

      return 
    $text;

    ?>

    gd script:
    <?php

      imageTTFText
    ($image$size$angle$x$y$color$font, include("temp.php"));

    ?>
    hope that helps!

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Posts
    29

    Re: Include statements in GD?

    Thanks guys i got it working

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width