Re: php in image alt tag
Posted: Fri Aug 24, 2018 2:26 pm
You can use PHP to display the value of a variable anywhere in a PHP page. There are several different variations to do this:
Code: Select all
// show just the $title variable
<img src="images/logo/logo.png" alt="<?php echo $title; ?>" title="">
// OR show the whole tag with single quotes by concatenating
<?php echo '<img src="images/logo/logo.png" alt="' . $title . '" title="">'; ?>
// OR show the whole tag and escape double quotes
<?php echo "<img src=\"images/logo/logo.png\" alt=\"$title\" title=\"\">"; ?>