Le point virgule de trop

Benoit VIGUIER

@b_viguier

AFUP Lyon 17/01/2023

Disclaimer


					echo "Guess my number, between 1 and 100 (5 attempts)\n";

					const MAX_ATTEMPT = 5;
					$number = rand(1, 100);
					$attempt = 1;
					

					[
					    print("Guess my number, between 1 and 100 (5 attempts)\n"),
					    define('MAX_ATTEMPT', 5),
					    $number = rand(1, 100),
					    $attempt = 1,
					];
					

					if([
					    print("Guess my number, between 1 and 100 (5 attempts)\n"),
					    define('MAX_ATTEMPT', 5),
					    $number = rand(1, 100),
					    $attempt = 1,
					]) {}
					

					for($attempt=1; $attempt<=MAX_ATTEMPT; ++$attempt) {
					    /** your code **/
					}
					

					foreach(range(1, MAX_ATTEMPT) as $attempt) {
					    /** your code **/
					}
					

					if ($attempt = 1) {}
					while ($attempt <= MAX_ATTEMPT) {
						if ([
							/** your code **/,
							$attempt++,
						]) {}
					}
					

					($recursion = function ($attempt = 1) use (&$recursion) {
						if (
							$attempt <= MAX_ATTEMPT
							&& [ /** your code **/ ]
							&& $recursion($attempt + 1)
						) {
						}
					})();
					

					switch($guess <=> $number) {
						case 0:
							echo "Victory!\n";
							exit(0);
						case -1:
							echo "Too low...\n";
							break;
						case 1:
							echo "Too high...\n";
							break;
					}
					

					match($guess <=> $number) {
						0 => [
							print("Victory!\n"),
							exit(0),
						],
						-1 => print("Too low...\n"),
						1 => print("Too high...\n"),
					};
					

Merci 🙇

Benoit VIGUIER

@b_viguier

AFUP Lyon 17/01/2023