3v4l.org

run code in 300+ PHP versions simultaneously
<?php //Enter your code here, enjoy! $pay_date = '20140808'; $cutoff_date = '20140728'; $next_bill_date = '20140808'; $recurrence = '3'; $today = date_create(); $cutoff_date = date_create_from_format('Ymd',$cutoff_date); $next_bill_date = date_create_from_format('Ymd',$next_bill_date); $pay_date = $next_bill_date; $outputstring = $pay_date->format('Ymd'); echo $outputstring; $days = ((int)date_format($pay_date, 'j'))-1; if ( $days > 0 ) { date_modify($pay_date, "-$days day"); } if($rec > 0){ $history = array ( 'account_id' => 'account', 'pay_amount' => '20.00', 'charity_id' => 'charity' ); if ($today > $cutoff_date) { date_modify($pay_date, '+1 month'); } for( $i = 1; $i <= $rec; ++$i ) { $history['pay_month'] = date_format($pay_date,'n'); $history['pay_year'] = date_format($pay_date,'Y'); print_r($history); if ( $i == $rec ) break; date_modify($pay_date, '+1 month'); } } else { $newData = array( 'charity_id' => $data['charity_id'], 'account_id' => $data['account'], 'action' => 'Unselected Charity : charity' ); print_r($newData); }
Output for 8.3.0 - 8.3.6
20140808 Warning: Undefined variable $rec in /in/KqAHX on line 26 Warning: Undefined variable $data in /in/KqAHX on line 53 Warning: Trying to access array offset on null in /in/KqAHX on line 53 Warning: Undefined variable $data in /in/KqAHX on line 54 Warning: Trying to access array offset on null in /in/KqAHX on line 54 Array ( [charity_id] => [account_id] => [action] => Unselected Charity : charity )
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
20140808 Warning: Undefined variable $rec in /in/KqAHX on line 26 Warning: Undefined variable $data in /in/KqAHX on line 53 Warning: Trying to access array offset on value of type null in /in/KqAHX on line 53 Warning: Undefined variable $data in /in/KqAHX on line 54 Warning: Trying to access array offset on value of type null in /in/KqAHX on line 54 Array ( [charity_id] => [account_id] => [action] => Unselected Charity : charity )
Output for 7.4.0 - 7.4.33
20140808 Notice: Undefined variable: rec in /in/KqAHX on line 26 Notice: Undefined variable: data in /in/KqAHX on line 53 Notice: Trying to access array offset on value of type null in /in/KqAHX on line 53 Notice: Undefined variable: data in /in/KqAHX on line 54 Notice: Trying to access array offset on value of type null in /in/KqAHX on line 54 Array ( [charity_id] => [account_id] => [action] => Unselected Charity : charity )
Output for 7.3.32 - 7.3.33
20140808Array ( [charity_id] => [account_id] => [action] => Unselected Charity : charity )
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.29 - 7.2.33, 7.3.12 - 7.3.31
20140808 Notice: Undefined variable: rec in /in/KqAHX on line 26 Notice: Undefined variable: data in /in/KqAHX on line 53 Notice: Undefined variable: data in /in/KqAHX on line 54 Array ( [charity_id] => [account_id] => [action] => Unselected Charity : charity )
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined function date_create_from_format() in /in/KqAHX on line 11
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Call to undefined function date_create() in /in/KqAHX on line 10
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: date_create() in /in/KqAHX on line 10
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: date_create() in /in/KqAHX on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: date_create() in /in/KqAHX on line 10

preferences:
259.14 ms | 401 KiB | 354 Q