CodeIgniter - php variable in a view (img src = a php variable) not working
<img src = "<?= $link ?>"></im开发者_运维百科g>
Short tags is enabled in php.ini and in config.php of codeigniter. Also tried
<img src = "<?php echo $link; ?>"></img>
but doesn't work. In the HTML output its just "", although a simple <?php echo $link; ?>
does work.
Are you actually passing the variable to the view via the load
call? See the "Adding Dynamic Data to a View" section of this page in the user guide.
Seems like the var isn't getting passed to the view.
Try:
<?php
$link="http://www.google.com/images/srpr/nav_logo13.png";
?>
<img src = "<?php echo $link; ?>"></img>
just to be certain there isn't something else going on. If you can see the image, something is preventing the var from getting to the view.
Can you edit your question to add the controller code that is sending the variable to the view?
精彩评论