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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners