Fergal 0 Posted August 11, 2011 Report Share Posted August 11, 2011 Page 18 of the book refers to the print function in the PHP manual - http://www.php.net/print. It says: ...the first value, int, says that print returns an integer value (specifically, print returns 1, always... I know how print "something" outputs a string, but I have no understanding as to how print always returns 1. Could someone please explain what is meant by the statement I quoted? Thanks! Quote Link to post Share on other sites
Larry 433 Posted August 11, 2011 Report Share Posted August 11, 2011 In this particular case, the fact that print returns 1 is meaningless. Or not meaningless, but not useful. What print does is output a string, but the function returns the integer 1. Normally the returned value is not used, but you could do this: if (print('Hello, world')) { ... That's how you might otherwise use a function that returns a "true" value. In this case, there's no need to ever do that because print always returns 1. Still, I use print() as an easy first example, because it's easy to understand what the function does and its definition. Quote Link to post Share on other sites
Fergal 0 Posted August 12, 2011 Author Report Share Posted August 12, 2011 Thanks Larry. ...the function returns the integer 1... What does that actually mean? Is 1 the same as TRUE in this instance? Quote Link to post Share on other sites
Jonathon 255 Posted August 12, 2011 Report Share Posted August 12, 2011 Yep 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.