Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling a PHP function
    primarykey
    data
    text
    <p>I've got the following function that generates and saves an image based a text parameter. How can I call this in my file? I tried </p> <pre><code>INCLUDE 'outPrice.php'; </code></pre> <p>to link to the external PHP and called it with this command,</p> <pre><code>outPrice($text); </code></pre> <p>To which I got the following response. </p> <pre><code>Warning: Cannot modify header information - headers already sent </code></pre> <p>Any help would be appreciated.</p> <pre><code>function outPrice($textval){ $textcolor = '666666'; $font="bgtbt.ttf"; $size = 20; $padding= 1; $bgcolor= "ffffff"; $transparent = 0; $antialias = 0; $fontfile = $fontpath.$font; $box= imageftbbox( $size, 0, $fontfile, $textval, array()); $boxwidth= $box[4]; $boxheight= abs($box[3]) + abs($box[5]); $width= $boxwidth + ($padding*2) + 1; $height= $boxheight + ($padding) + 0; $textx= $padding; $texty= ($boxheight - abs($box[3])) + $padding; // create the image $png= imagecreate($width, $height); $color = str_replace("#","",$bgcolor); $red = hexdec(substr($bgcolor,0,2)); $green = hexdec(substr($bgcolor,2,2)); $blue = hexdec(substr($bgcolor,4,2)); $bg = imagecolorallocate($png, $red, $green, $blue); $color = str_replace("#","",$textcolor); $red = hexdec(substr($textcolor,0,2)); $green = hexdec(substr($textcolor,2,2)); $blue = hexdec(substr($textcolor,4,2)); $tx = imagecolorallocate($png, $red, $green, $blue); imagettftext( $png, $size, 0, $textx, $texty, $tx, $fontfile, $textval ); header("content-type: image/jpeg"); imagejpeg($png, "price".$textval.".jpg"); imagedestroy($png); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload