Jump to content

inserting html code in to php codings


karthikanov24

Recommended Posts

How and where can we use the following statement of html coding,

 

<img src="<?php echo $dest;?>">      and

<img src="<?php eho $src;?>">

 

to get or see the image inside the php codes posted below

<?php
function copyImage($srcFile, $destFile, $w, $h, $quality = 75)
{
    $tmpSrc     = pathinfo(strtolower($srcFile));
    $tmpDest    = pathinfo(strtolower($destFile));
    $size       = getimagesize($srcFile);

    if ($tmpDest['extension'] == "gif" || $tmpDest['extension'] == "jpg")
    {
       $destFile  = substr_replace($destFile, 'jpg', -3);
       $dest      = imagecreatetruecolor($w, $h);
       imageantialias($dest, TRUE);
    } elseif ($tmpDest['extension'] == "png") {
       $dest = imagecreatetruecolor($w, $h);
       imageantialias($dest, TRUE);
    } else {
      return false;
    }
echo $dest;

    switch($size[2])
    {
       case 1:       //GIF
           $src = imagecreatefromgif($srcFile);
           break;
       case 2:       //JPEG
           $src = imagecreatefromjpeg($srcFile);
           break;
       case 3:       //PNG
           $src = imagecreatefrompng($srcFile);
           break;
       default:
           return false;
           break;
    }

    imagecopyresampled($dest, $src, 0, 0, 0, 0, $w, $h, $size[0], $size[1]);
    
    switch($size[2])
    {
       case 1:
       case 2:
           imagejpeg($dest,$destFile, $quality);
           break;
       case 3:
           imagepng($dest,$destFile);
    }
    return $destFile;

}
?>

-------------

Thanks,

Karthikanov24

 

Link to comment
https://forums.phpfreaks.com/topic/174885-inserting-html-code-in-to-php-codings/
Share on other sites

okay.. you CAN'T do what you're interested in, however, you CAN do it with a little run-around.

 

create a php file and put that php code inside (the code that generates the image) THEN just do <img src='whateverThatPHPFileWasNamed.php' />

hi

thanks...Is that the php file look like this

say name of the php file is abc.php

<?php
$dest=imagecreatetruecolor($w,$h);
echo $dest;
?>

 

and <img src> tag is used in the following funtion which is in another file....like this...at line 12 ?

 

function copyImage($srcFile, $destFile, $w, $h, $quality = 75)
{
    $tmpSrc     = pathinfo(strtolower($srcFile));
    $tmpDest    = pathinfo(strtolower($destFile));
    $size       = getimagesize($srcFile);

    if ($tmpDest['extension'] == "gif" || $tmpDest['extension'] == "jpg")
    {
       $destFile  = substr_replace($destFile, 'jpg', -3);
       $dest      = imagecreatetruecolor($w, $h);
       imageantialias($dest, TRUE);
echo "<img src="abc.php">";
    } elseif ($tmpDest['extension'] == "png") {
       $dest = imagecreatetruecolor($w, $h);
       imageantialias($dest, TRUE);
    } else {
      return false;
    }

could u give me the exact codings thru an example, please..

Thanks,

karthikanov24

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.