WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Get Nothing when Calling Function in PHP (2 posts)

  1. pdxchambers
    Member
    Posted 1 year ago #

    I'm in the process of developing a calendar plugin. I have a couple of functions nextMonth() and prevMonth() that are supposed to take in an integer value for the month and year and display the calendar for the next/previous month respectively... seems pretty simple, however nothing is being displayed and I've run out of potential ideas...

    function nextMonth ( $month, $year) {
         if ( $month == 12 ) {
              Display_Calendar( 1, ( $year + 1 ) );
         } else {
              Display_Calendar ( ( $month + 1 ), $year) );
         }
    }

    The prevMonth() function is identical except it checks if the month is January and returns either December of the previous year or the previous month. I've already tested theDisplay_Calendar() function separately and it works perfectly fine.

    In my test code I'm calling the nextMonth() function directly:

    echo nextMonth(3, 2012);

    What I expect is to see a calendar for April 2012, but I get nothing instead. Everything seems to test out semantically, no errors in the IDE, no errors in the browser, it simply doesn't display. Any ideas as to what might be going on here?

  2. pdxchambers
    Member
    Posted 1 year ago #

    Just realized the problem... no return statement means nothing gets output. Added return to both functions and they work!

    **FACEPALM**

Topic Closed

This topic has been closed to new replies.

About this Topic