PHP What is wrong with recursive function? -



PHP What is wrong with recursive function? -

i did function showing today date or next workday date, if weekend. function works great, homecoming wrong.

$today = todaydate('2014-10-18'); // saturday function todaydate($date) { if(date('n', strtotime($date)) >= 6) { echo 'if - ' . $date . '<br/>'; $date = date('y-m-d', strtotime('+1 day', strtotime($date))); todaydate($date); } else { echo 'else - ' . $date . '<br/>'; } homecoming $date; } echo '<br/><br/>today: ' . $today . '<br/><br/>';

this function echoes following:

if - 2014-10-18 if - 2014-10-19 else - 2014-10-20

but echo of $today (last row in code) is

today: 2014-10-19

so, wrong? lastly $date in function "2014-10-20" , value returning $today, $today shows different value. idea?

as kojiro pointed out in comment, not assign homecoming value of inner phone call todaydate(). alter this, replace line

todaydate($date);

with

$date = todaydate($date);

php

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -