When I generate the src of an img tag, using php, it strips the forward slash at the end of the tag. Anyone come across this before?
If I have the path to an image stored in $thumbPath
and I put tha开发者_开发知识库t as the img tag's src it strips the end "/" from the tag. Does anyone have any ideas about this?
<img src="<?php echo $thumbPath; ?>" />
// <img src="path/to/file/foo.jpg">
Thanks
It seems very unlikely that this is the location of the problem. "echo" is not semantically aware. It's much more likely that the error exists in whatever code is generating $thumbPath
.
Here's a test to show that Wrikken et al. are correct:
<?php
ob_start();
$thumbPath = 'path/to/file/foo.jpg';
?>
<img src="<?php echo $thumbPath; ?>" />
<?php
echo htmlspecialchars(ob_get_clean());
// Output:
// Browser: <img src="path/to/file/foo.jpg" />
// CLI: <img src="path/to/file/foo.jpg" />
It will not strip it. As the /
is outside the scope of the code you have provided us with. The source of the problem is something else, without any more info I can't help you.
精彩评论