Cannot get this one correct and working, though simple!

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 12-30-2005
Pedro Graca
 
Posts: n/a
Default Re: Cannot get this one correct and working, though simple!

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!
Reply With Quote
  #12 (permalink)  
Old 01-02-2006
Jofio
 
Posts: n/a
Default Re: Cannot get this one correct and working, though simple!

Thank you all for helping. It is working now... Once again, many
thanks..


jofio

Reply With Quote
  #13 (permalink)  
Old 01-03-2006
comp.lang.php
 
Posts: n/a
Default Re: Cannot get this one correct and working, though simple!


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


Reply With Quote
  #14 (permalink)  
Old 01-03-2006
Oli Filth
 
Posts: n/a
Default Re: Cannot get this one correct and working, though simple!

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
Reply With Quote
  #15 (permalink)  
Old 01-05-2006
Gleep
 
Posts: n/a
Default Re: Cannot get this one correct and working, though simple!

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


Reply With Quote
  #16 (permalink)  
Old 01-08-2006
Jofio
 
Posts: n/a
Default Re: Cannot get this one correct and working, though simple!

Yes, similar page...but I am developing it on my PC. Thanks..I
enjoyed your gallery.

Jofio

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:47 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0