db_programmer Posted July 8, 2009 Share Posted July 8, 2009 I have been writing some PHP code, and I just recently realized that I have not been including a return statement in my functions that do not return any values. This hasn't seemed to affect my functionality at all. EXAMPLE: function my_function($blah) { //Do this //Do this //Do this } instead of function my_function($blah) { //Do this //Do this //Do this return; } I just wanted to know whether it made any difference one way or the other whether I include return; at the end of each function, or if it is unnecessary as it seems. Thanks, dbp Quote Link to comment https://forums.phpfreaks.com/topic/165196-solved-return-statement/ Share on other sites More sharing options...
p2grace Posted July 8, 2009 Share Posted July 8, 2009 It isn't necessary if you are not actually returning a variable. It just acts as a void. Quote Link to comment https://forums.phpfreaks.com/topic/165196-solved-return-statement/#findComment-871089 Share on other sites More sharing options...
Maq Posted July 8, 2009 Share Posted July 8, 2009 Have you read the documentation - return? Quote Link to comment https://forums.phpfreaks.com/topic/165196-solved-return-statement/#findComment-871095 Share on other sites More sharing options...
db_programmer Posted July 8, 2009 Author Share Posted July 8, 2009 Thanks, I appreciate the quick response. I just need to make sure there are no senseless issues with my code that could have been prevented. Since C++/Java are my first languages, it made me stop for a second. Cheers, dbp Quote Link to comment https://forums.phpfreaks.com/topic/165196-solved-return-statement/#findComment-871097 Share on other sites More sharing options...
p2grace Posted July 8, 2009 Share Posted July 8, 2009 If your question has been answered could you also mark the post topic as "Solved"? Cheers, p2grace Quote Link to comment https://forums.phpfreaks.com/topic/165196-solved-return-statement/#findComment-871100 Share on other sites More sharing options...
db_programmer Posted July 8, 2009 Author Share Posted July 8, 2009 Have you read the documentation - return? I had not. Quote Link to comment https://forums.phpfreaks.com/topic/165196-solved-return-statement/#findComment-871105 Share on other sites More sharing options...
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.