Welcome to WebmasterWorld Guest from 126.96.36.199
Very simple thing: I'm using an array to have a random imager on some new pages.
When I embed the img src in the array, I can't use the traditional "" around the .jpg, otherwise it messes up the array.
array("<img src=../images/someimage.jpg width=150 height=130 border=1 alt=Image Title>",
array("<img src="../images/someimage.jpg" width="150" height="130" border="1" alt="Image Title">",
Of course, the first example spits out the image code with no "" in it. I tested it in IE 5.0 and NN 4.7 - and it works. I know from our site stats that there's NO browsers below either of those examples.
But I'm wondering if a lack of "" around the img src tags will cause trouble in other browsers?
Any thoughts on this? Or how to work around it?
Thanks for your time
alternately you may be able do it automatically by this:
$string = "<img src="../images/someimage.jpg" width="150" height="130" border="1" alt="Image Title">";
I didn't test either of these.
[edited by: lorax at 7:12 pm (utc) on Aug. 23, 2002]
array('<img src="../images/someimage.jpg" width="150" height="130" border="1" alt="Image Title">';
You can almost always avoid having to escape quotes by using a quoting operator that is not used in the string itself. If you were using perl that wouldnīt be any problem since it has a real quoting operator. But even in php it is quite easy using the heredoc syntax as explained in [php.net...]
$str = <<<EOD
<p class="ac">Example of string
spanning multiple lines
using 'heredoc' syntax.</p>
Note the use of both " and ' without having to escape those characters since we use heredoc syntax to mark beginning and end of the string.
Your very simple solution of using single quotes - ' ' instead of "" works like a charm.
Knowing about the heredoc syntax will also be helpful for the future, I'm sure.
A thousand thank-you's... I'm sorry I didn't test the other examples, but I appreciate everyone's input.