PHP: Flip a coin

In this post, we will write a small program that will flip a coin for us. Let’s start

<style>
	.coin {
		background: #e2e2e2;
		color: #333333;
		border-radius: 50%;
		padding: 50px;
		text-align: center;
		font-size: 2rem;
		font-weight: bold;
		width: 50px;
	}
</style>
<?php

function flip() {
	return 0 == rand(0,1) ? 'Head' : 'Tail';

?>
<div class="coin">
	<?php echo flip(); ?>
</div>

Random outcome will be on page refresh as following.

Functional example:
https://code.danyal.dk/php/flip-coin.php

Author: Danyal
I'm a skilled programmer specializing in Vue.js/Nuxt.js for front-end development and PHP Laravel for back-end solutions. I have a strong focus on API design and development, complemented by experience in web server setup and maintenance. My versatile expertise ensures seamless creation and maintenance of web applications, covering everything from intuitive user interfaces to robust server-side functionality. Passionate about coding and driven by a lifelong learning mindset, I invite you to explore more at danyal.dk.