note 8933 deleted from language.operators.logical by irc-html

From: Date: Sat, 19 Jan 2002 19:16:10 +0000
Subject: note 8933 deleted from language.operators.logical by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25232@lists.php.net to get a copy of this message
[Editor's note: Understanding the difference between echo and print would have saved much time and aggravation 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] 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.

« previous php.notes (#25232) next »