Shimsham84
Shimsham84

Reputation: 327

Codeigniter image tag - errors occurring

I use codeigniter as my framework and testing a site on a localhost. At the moment I am using img tags as the following:

<img src="<?php echo base_url(); ?>/assets/images/image.png" class="home"/>

This shows the image- great, but when validating html I get the following message:

"Character "<" is the first character of a delimiter but occurred as data This message may appear in several cases:

I have also tried the Codeigniter html helper of the img tag array and when I do this it doesn't show the image and any code underneath this line does not show.

Any suggestions to mark this code better or a way of passing the validation checks as I like to be 100% pass rate.

Upvotes: 0

Views: 492

Answers (2)

xelber
xelber

Reputation: 4637

Try using site_url

<img src="<?php echo site_url('/assets/images/image.png');?>" class="home"/>

Upvotes: 2

sandip
sandip

Reputation: 3289

please remove / at the end of the

base_url()

base_user function by default provides / at the end use this way

<img src="<?php echo base_url();?>assets/images/image.png" class="home"/>

Upvotes: 1

Related Questions