Re: [PHP] Comma question

2002-07-22 Thread Miguel Cruz

On Mon, 22 Jul 2002, B i g D o g wrote:
> I figured that the comma was to concatenate but is was wondering if the
> parser handled it different.

The comma isn't actually for concatenation. The net effect is the same in 
this case, but a very different thing is happening.

  echo "hello " , "there";

Here 'echo' is printing two separate arguments. First it is printing 
"hello " and then it is printing "there".

  echo "hello " . "there";

Here the strings are concatenated to form a single string ("hello there") 
and then this is processed by echo which prints it out.

The effects are the same, as I said, but it's important to realize why 
they're very different ways of getting that effect.

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Comma question

2002-07-22 Thread Justin French

on 23/07/02 8:34 AM, B i g D o g ([EMAIL PROTECTED]) wrote:

> What does the "," and "{}" do in this type of statement?
> 
> Example:  echo "{$strName}", htmlspecialchars( $teststr );


Not sure about the comma, but the {braces} are easy.  They help separate the
$vars from other stuff in the string.

Example:



It's a good habbit to get into, and has saved my arse on a few occasions,
although the above example isn't a good one.


Justin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Comma question

2002-07-22 Thread Martin Towell

I remember from a previous post, the dot operator will create a temporary
string in memory, and then echo that out. The comma operator will just
output as it goes - ie. it doesn't create a temporary string.


As for Lee Doolan's reply:
  echo "{$obj->strName[$i]}";
interesting - never thought of doing that, I alway's broke out of the quotes
to do object dereferencing. Should make my future code more readable I
think...

Martin

-Original Message-
From: B i g D o g [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 23, 2002 9:06 AM
To: PHP GEN
Subject: Re: [PHP] Comma question


Thanks all for the info...

I figured that the comma was to concatenate but is was wondering if the
parser handled it different.

I knew the {} helped the parser now which was the variable...but i have
never seen it like that...

I have only seen it like ${var}...

Just wondering the difference...



.: B i g D o G :.


- Original Message -
From: "Kevin Stone" <[EMAIL PROTECTED]>
To: "B i g D o g" <[EMAIL PROTECTED]>; "PHP GEN"
<[EMAIL PROTECTED]>
Sent: Monday, July 22, 2002 5:00 PM
Subject: Re: [PHP] Comma question


> Curly braces {} are sometimes required for PHP to properly parse variables
> within quoted strings.  Good example might be defining variable-variables
> within a quoted string  "${$myvarvar}".  However I do not believe that
curly
> braces are required in this particular string.
>
> As for the comma I believe it does the same thing as the period.  It will
> concatonate the quoted string with the output of the htmlspecialchars()
> function within the echo statement.
>
> -Kevin
>
> - Original Message -
> From: "B i g D o g" <[EMAIL PROTECTED]>
> To: "PHP GEN" <[EMAIL PROTECTED]>
> Sent: Monday, July 22, 2002 4:34 PM
> Subject: [PHP] Comma question
>
>
> > Tried to check the archive, but it is offline...
> >
> >
> > What does the "," and "{}" do in this type of statement?
> >
> > Example:  echo "{$strName}", htmlspecialchars(
> $teststr );
> >
> > Thanks,
> >
> >
> > .: B i g D o g :.
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Comma question

2002-07-22 Thread B i g D o g

Thanks all for the info...

I figured that the comma was to concatenate but is was wondering if the
parser handled it different.

I knew the {} helped the parser now which was the variable...but i have
never seen it like that...

I have only seen it like ${var}...

Just wondering the difference...



.: B i g D o G :.


- Original Message -
From: "Kevin Stone" <[EMAIL PROTECTED]>
To: "B i g D o g" <[EMAIL PROTECTED]>; "PHP GEN"
<[EMAIL PROTECTED]>
Sent: Monday, July 22, 2002 5:00 PM
Subject: Re: [PHP] Comma question


> Curly braces {} are sometimes required for PHP to properly parse variables
> within quoted strings.  Good example might be defining variable-variables
> within a quoted string  "${$myvarvar}".  However I do not believe that
curly
> braces are required in this particular string.
>
> As for the comma I believe it does the same thing as the period.  It will
> concatonate the quoted string with the output of the htmlspecialchars()
> function within the echo statement.
>
> -Kevin
>
> - Original Message -
> From: "B i g D o g" <[EMAIL PROTECTED]>
> To: "PHP GEN" <[EMAIL PROTECTED]>
> Sent: Monday, July 22, 2002 4:34 PM
> Subject: [PHP] Comma question
>
>
> > Tried to check the archive, but it is offline...
> >
> >
> > What does the "," and "{}" do in this type of statement?
> >
> > Example:  echo "{$strName}", htmlspecialchars(
> $teststr );
> >
> > Thanks,
> >
> >
> > .: B i g D o g :.
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Comma question

2002-07-22 Thread Demitrious S. Kelly

I think someone working on learning php after learning C was a little
too printf() happy :)

-Original Message-
From: B i g D o g [mailto:[EMAIL PROTECTED]] 
Sent: Monday, July 22, 2002 3:34 PM
To: PHP GEN
Subject: [PHP] Comma question

Tried to check the archive, but it is offline...


What does the "," and "{}" do in this type of statement?

Example:  echo "{$strName}", htmlspecialchars(
$teststr );

Thanks,


.: B i g D o g :.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Comma question

2002-07-22 Thread Kevin Stone

Curly braces {} are sometimes required for PHP to properly parse variables
within quoted strings.  Good example might be defining variable-variables
within a quoted string  "${$myvarvar}".  However I do not believe that curly
braces are required in this particular string.

As for the comma I believe it does the same thing as the period.  It will
concatonate the quoted string with the output of the htmlspecialchars()
function within the echo statement.

-Kevin

- Original Message -
From: "B i g D o g" <[EMAIL PROTECTED]>
To: "PHP GEN" <[EMAIL PROTECTED]>
Sent: Monday, July 22, 2002 4:34 PM
Subject: [PHP] Comma question


> Tried to check the archive, but it is offline...
>
>
> What does the "," and "{}" do in this type of statement?
>
> Example:  echo "{$strName}", htmlspecialchars(
$teststr );
>
> Thanks,
>
>
> .: B i g D o g :.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Comma question

2002-07-22 Thread Evan Nemerson

The comma just concatenates the two. The brackets don't seem to do much of 
anything...

echo "$strName".htmlspecialchars( $teststr );

seems to be the same...



PS sorry to everyone who got an eMail with a screwed up time- I forgot to fix 
the clock after i re-installed winblows (dual-boot)


-- 
If you pick up a starving dog and make him prosperous, he will not bite you; 
that is the principal difference between a dog and a man.

Samuel Clemens



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php