3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getUsersData( \PDO $pdo) { $query = $pdo->query( "SELECT name,mail FROM users" ); return $query->fetchAll( PDO::FETCH_OBJ ) ; } function calculateDate( $date ) { $currentDate = new DateTime(); $diff = $currentDate->diff( new DateTime($date) ) ; return $diff; } $users = getUsersData($connection); foreach( $users as $user ){ $dateEnd = calculateDate( $user->date ); $message = sprintf("Twoj abonamnet konczy sie %s" , $dateEnd->format("d-m-Y")); // mailer }
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $connection in /in/jWhUp on line 15 Fatal error: Uncaught TypeError: getUsersData(): Argument #1 ($pdo) must be of type PDO, null given, called in /in/jWhUp on line 15 and defined in /in/jWhUp:3 Stack trace: #0 /in/jWhUp(15): getUsersData(NULL) #1 {main} thrown in /in/jWhUp on line 3
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
39.02 ms | 401 KiB | 8 Q