title: Image display using php without affecting the html code
body: <p>I have a question about the images displaying using a function getImage_w($image,$dst_w), which takes the image URL ($image) and the destination width for this image ($size). Then it re-draws the image changing its height according to the destination width.</p>
  
  <p>That's the function (in libs/image.php file):</p>
  
  <pre><code>function getImage_w($image,$w){
         /*** get The extension of the image****/
        $ext= strrchr($image, ".");
         /***check if the extesion is a jpeg***/
          if (strtolower($ext)=='.jpg' || strtolower($ext)=='.jpeg'){
         /***send the headers****/
          header('Content-type: image/jpeg');
          /**get the source image***/
          $src_im_jpg=imagecreatefromjpeg($image);
          /****get the source image size***/
          $size=getimagesize($image);
          $src_w=$size[0];
          $src_h=$size[1];
          /****calculate the distination height based on the destination width****/
          $dst_w=$w;
          $dst_h=round(($dst_w/$src_w)*$src_h);
          $dst_im=imagecreatetruecolor($dst_w,$dst_h);
          /**** create a jpeg image with the new dimensions***/
          imagecopyresampled($dst_im,$src_im_jpg,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h);
          imagejpeg($dst_im);
  }
  </code></pre>
  
  <p>In a file imagetest.php I have this code portion:</p>
  
  <pre><code>&lt;?php
  require 'libs/image.php';
  echo '&lt;h1&gt;HELLO WORLD : some html&lt;/h1&gt;
  &lt;img src="'.displayImg_w('http://www.sanctius.net/wp-content/uploads/2010/05/Avatar-20.jpg',200).'"&gt;
  ';
  </code></pre>
  
  <p>In the past, I used to write the URL with $_GET paramers defining the image. But now , I want to use the function directly in my code.</p>
  
  <p>The problem is that the image is displaying correctly, but the <h1>Hello World</h1> HTML code is not translated by the browser (I know that the header are already sent by the first code) But I want to know how to display the image correctly without affecting the html code. and also without using get parameters that change the URL of the image to this undesired form :</p>
  
  <blockquote>
    <p>libs/image.php?image=<a href="http://www.example.com/image&amp;width=200" rel="nofollow noreferrer">http://www.example.com/image&amp;width=200</a></p>
  </blockquote>