Insert an image into index.php file

Hi, how do I insert an image into my index.php file? As of now it looks like this:

echo (“Hello”);

Many thanks,

You insert images with php in much the same way you insert images with html.

If you are wanting to stay in php, echo the html code.

echo ' 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "">
<img src="/images/image1.png" width="280" height="125" title="Logo of a company" alt="Logo of a company" />


I left out a lot of the html code that should be on most pages.

If you just want to use a little php, you can just use short bits of php inserted where you need it.

Some html pages actually using the php include to create parts of the website that are repeated on many (or all) pages. If you want to include an image on every page, copy the code you use on your page and save it to a include folder besing sure to start and stop the code with the php start and stop tags.

Then locate the place you want the image to show on your webpage, and use code similar to this:
<?php include($_SERVER[‘DOCUMENT_ROOT’]."/include/logo.php") ?>

If that was not what you are looking for, try restating your question.

The server will compile the php code , and send it along with your php file.

So you can just

<html><head><title><?php echo "cool title";?></title></head>

<img src="<?php echo $image_url;?>">

<br><h1>Got me?</h1>

A php file can contain a combination of html, css and javascript. If your web page file name has a .php extension, the web page is first sent to the “php engine” on the web server where all the php code is run before sending the web page and any output from the php code down to the browser.

So depending where your image is coming from, inserting an image in your index.php could be as simple as


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="">
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        echo ("Hello");
            <img src="myPic.jpg" alt="myPic" />


You can insert image in Index.php file by(<img src=“myPic.jpg”>) img src command.