This is a discussion on Cannot get this one correct and working, though simple! within the PHP Language forums, part of the PHP Programming Forums category; Jerry Stuckle wrote: > Geoff Berrow wrote: >> Message-ID: <IU5yAgAsnQtDFw$+@eminent.demon.co.uk> from Peter ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Jerry Stuckle wrote:
> Geoff Berrow wrote: >> Message-ID: <IU5yAgAsnQtDFw$+@eminent.demon.co.uk> from Peter Fox >> contained the following: >> >> >>>>But my problem is that part of the code ...<img src='thumb$i.jpg'> ... >>> >>>Single quotes! Try Double. >> >> >> Single quotes are fine as is the code AFAICT. >> > > No, with single quotes $i is not expanded. It would be with double quotes. Single quotes *within* double quotes, as the OP had, do not stop PHP from interpolating the variables! Try it <?php $name = 'Jerry'; echo "Name is $name"; /* only double quotes */ echo 'Name is $name'; /* only single quotes */ echo "Name is '$name'"; /* single quotes *within* double quotes */ echo 'Name is "$name"'; /* double quotes *within* single quotes */ ?> -- Mail to my "From:" address is readable by all at http://www.dodgeit.com/ == ** ## !! ------------------------------------------------ !! ## ** == TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>) may bypass my spam filter. If it does, I may reply from another address! |
|
|||
|
Oli Filth wrote: > comp.lang.php said the following on 30/12/2005 16:16: > > Jofio wrote: > > > >> > >>But my problem is that part of the code ...<img src='thumb$i.jpg'> ... > >> > > > > The problem lies in the way you embedded $i. PHP thinks you have a > > variable literally called "$i.jpg" since a period is a valid implied > > variable name character. > > > > Umm, no... Who told you that? The PHP manual. Assuming that is still your authority on PHP. "Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'" >From http://us3.php.net/language.variables Sorry to be off-topic. Phil > > The problem is the use of single quotes rather than double quotes. > > -- > Oli |
|
|||
|
comp.lang.php said the following on 03/01/2006 17:50:
> Oli Filth wrote: > >>comp.lang.php said the following on 30/12/2005 16:16: >> >>>Jofio wrote: >>> >>>>But my problem is that part of the code ...<img src='thumb$i.jpg'> ... >>> >>>The problem lies in the way you embedded $i. PHP thinks you have a >>>variable literally called "$i.jpg" since a period is a valid implied >>>variable name character. >> >>Umm, no... Who told you that? > > The PHP manual. No it didn't. > "Variable names follow the same rules as other labels in PHP. A valid > variable name starts with a letter or underscore, followed by any > number of letters, numbers, or underscores. As a regular expression, it > would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'" Where is a period mentioned in that quote? Indeed, as a counter-quote from the manual: > "However, it should be noted that the dot (period, full stop) is not > a valid character in a PHP variable name." (http://www.php.net/manual/en/languag...l.dot-in-names) Think about it - it's the string concatenation operator - how could it be used as a character in a variable name? -- Oli |
|
|||
|
I wrote something last year that sort of does what you want see this for example
http://www.allelsefailedind.com/2005/gallery.php it's a gallery in frame and you click on the thumb and it shows the larger one on the right. I have 400 images and they are all in a folder, then I used a tool thumbnail express to create the thumbs for the frame, then I used some php to make the thing work if you need more detailed explanation and example write me at jasgleep@hotmail.com On 29 Dec 2005 22:31:34 -0800, "Jofio" <j9k22000@yahoo.com> wrote: >I have 40 or jpeg files which I want them displayed in a frame called >"main" upon clicking thumbnails of the same pics in a "leftMenu" frame. >The thumbnail jpeg files are called thumb1, thumb2, thumb3, thumb4, >..., thumb40. These files are smaller versions (50pixelX50pixel) of the >larger jpeg files called 1, 2, 3, 4, ..., 40 which I want them >displayed. > >To display the hyperlinked thumbnails in the "leftMenu" frame I have it >in a loop. [See the code snippet] > >But my problem is that part of the code ...<img src='thumb$i.jpg'> ... > >It doesn't display the intended thumbnail jpeg files; instead, it >display the larger version of the files as thumbnails which takes >longer to load. > >Here's my loop: > ><?php > for ( $i = 1; $i < 40; $i++) { > if ($i!=17) { > echo "<a href='$i.jpg' target='main'><img src='thumb$i.jpg'></a> > > } > } >?> > >Any help? Many thanks in advance. > > >jofio |