Re: note 8933 added to Logical Operators
| From: | J. M. Castagnetto | Date: | Fri, 06 Oct 2000 23:19:06 +0000 |
| Subject: | Re: note 8933 added to Logical Operators | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-6193@lists.php.net to get a copy of this message | ||
Understanding the difference between echo and print
would have save much time and aggavation in the case
below.
This a known behavior: "print" returns a boolean on
success, "echo" is a language construct and does not
return a value. Therefore is no surprise that the
constructs you are using failed w/ echo and succeded
w/ print.
This is also noted in a comment to the manual entry
for "print", and in the PHP Knowledge base
(php.faqts.com):
http://www.faqts.com/knowledge-base/view.phtml/aid/1/fid/41
(The paragraphs above will be added to your note)
--- tech@squiz.net wrote:
> My brain still stings.
>
> The following conundrum has just devoured several
> hours of my time.
> I wanted to output a certain string if a variable
> had a certain value. I tried:
>
> ($foo == "some value") && (echo ("some string"));
>
> I bravely offered it to PHP innumerable times, and
> all I got was a lousy "Parse error". No one knew
> what the problem was.
>
> When I finally tried:
> ($foo == "some value") && (print ("some string"));
> it worked flawlessly.
>
> Be warned.
>
> Echo evidently has issues. If you get a weird error
> with echo (in this particular context, or
> elsewheres) try print instead.
>
>
>
http://www.php.net/manual/language.operators.logical.php
>
>
>
> --
> PHP Notes Mailing List (http://www.php.net/)
> To unsubscribe, e-mail:
> php-notes-unsubscribe@lists.php.net
> For additional commands, e-mail:
> php-notes-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>
=====
--- Jesus M. Castagnetto (jcastagnetto@yahoo.com)
__________________________________________________
Do You Yahoo!?
Yahoo! Photos - 35mm Quality Prints, Now Get 15 Free!
http://photos.yahoo.com/