Re: Image and variable
| From: | Torsten Roehr | Date: | Tue, 10 Aug 2004 12:02:35 +0000 |
| Subject: | Re: Image and variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-193259@lists.php.net to get a copy of this message | ||
"Henri marc" <mesmlamoi@yahoo.fr> wrote in message
news:20040810114736.98514.qmail@web50104.mail.yahoo.com...
> Hello,
>
> I would like to use a variable instead of an image
> file name in a html page with this instruction:
>
> <?php
> echo '<img src="$myimage">';
> ?>
>
> I tried but the image doesn't show up. Is it
> impossible or do I do something wrong?
> My goal is to have a random image print in the page,
> that's why I want to use a variable.
>
> Thank you for your good advices.
Variables in single-quoted strings are not evaluated. Either user double
quotes or concatination:
echo "<img src=\"$myimage\">"; or
echo '<img src="' . $myimage . '">';
Regards, Torsten Roehr