Fergal Posted August 11, 2011 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! Link to comment Share on other sites More sharing options...
Larry Posted August 11, 2011 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. Link to comment Share on other sites More sharing options...
Fergal Posted August 12, 2011 Author 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? Link to comment Share on other sites More sharing options...
Jonathon Posted August 12, 2011 Share Posted August 12, 2011 Yep 1 Link to comment Share on other sites More sharing options...
Recommended Posts