Compiling PHP's conditional statements to Rust It's time to take another step into compilation land and look at compiling PHP's conditional statements (if statements) into Rust code. The goal for this post will be compiling the following code: $guess = readline("Guess a number between 1 and 3: "); $number = rand(1, 3); if ($guess == $number) { echo "You guessed the number correctly, well done!"; } else { echo "The correct answer is ".

An assignment expression in the Rust code will be represented with a let statement.

For now it compiles the initial if statement and checks to see if there is a valid else statement at the end.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners