javascript - HTML tag <em> appearing on live website only
I am creating a website using php with javascript and jquery. Everything seems to be normal when I see the output locally, but when I upload it live, some parts of the website gets affected by the tag. I did not even try to add this tag before.
My bootstrap grid does not stay on one row anymore and some of my paragraph tags and headers turn italic all of a sudden. What or where is the origin of this tag?
This is my php for each to output the contents of my database. It echos a picture, a header tag, a paragraph tag and a "Read More" link. Locally they are all the same, but in the live website as you can see, the second output has its "Read More" in italic only but the third one has it on every text.
<?php
foreach($lstBlog as $rowBlog) {
$datetime = new DateTime($rowBlog['createddate']);
echo'<div >';
echo'<div >';
echo'<img src="img/_uploads/blog/'.$rowBlog['featured_photo_thumb'].'">';
echo'<div >';
echo'<p >'.$datetime->format('F j, Y').'</p>';
echo'<h4 >'.$rowBlog['blog_name'].'</h4>';
echo'<p >';
echo substr($rowBlog['blog_description'], 0, 100);
echo strlen($rowBlog['blog_description']) > 100 ? ".....</p>" : "</p>";
echo'<a href="blog.php?i='.$rowBlog['blogid'].'">';
echo'<h4 >Read More</h4></a></div></div></div>';
} ?>
Answer
Solution:
I think that your issue might be coming from discrepancies between what you have in your local environment and what you have in the production environment. At a glance, just looking at the screenshot, I'm guessing that something in the second column opens the
<em>
tag and then doesn't close it.This makes me think that this might be an issue with how you generate that excerpt in that section, are you stripping all the HTML? Just from the screenshot, I can see a situation where it's getting 'trimmed' and closing, not including the enclosing
<em>
tag.If my theory is correct, what you'd have to do is ensure that the output that is generated for the excerpt doesn't include any HTML (stripped).
As mentioned in one of the comments by shadowdev to your original question, the relevant function that you're looking for is strip_tags()
A more in-depth explanation to accomplish what you're trying to do can be found in another question:
Truncate text containing HTML, ignoring tags