Page 1 of 1
PHP coding. How to replace statement by variable?
Posted: Sat Oct 24, 2009 7:37 am
by azadms
I have the following code working fine with
echo '<img src = "adsphotos/myphoto.jpg" width="100" height="90" hspace="10" border="0" />';
Any one tell me how to replace "adsphotos/myphoto.jpg" by a variable like $filename and modify the coding?
It is not accepting :
$filename="adsphotos/myphoto.jpg";
echo '<img src = $filename width="100" height="90" hspace="10" border="0" />';
Re: PHP coding. How to replace statement by variable?
Posted: Sat Oct 24, 2009 7:42 am
by yempee
<?php
$filename="images.jpeg";
echo '<img src = '.$filename.' width="100" height="90" hspace="10" border="0" />';
?>
Can u try the above one....
Re: PHP coding. How to replace statement by variable?
Posted: Sat Oct 24, 2009 8:10 am
by Mark Baker
Slight fix yempee, quotes around the image src
Code: Select all
$filename="adsphotos/myphoto.jpg";
echo '<img src = "'.$filename.'" width="100" height="90" hspace="10" border="0" />';
Re: PHP coding. How to replace statement by variable?
Posted: Sat Oct 24, 2009 8:21 am
by jackpf
Re: PHP coding. How to replace statement by variable?
Posted: Sat Oct 24, 2009 8:31 am
by azadms
Really appreciating your fast reply. This reduces my headache. I tried to get information on net but I could not. Thank you very much once again.
Re: PHP coding. How to replace statement by variable?
Posted: Sat Oct 24, 2009 3:47 pm
by veldthui
azadms wrote:Really appreciating your fast reply. This reduces my headache. I tried to get information on net but I could not. Thank you very much once again.
Gee and I thought this was the net

. My bad.