PHP: Flip a coin

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

	.coin {
		background: #e2e2e2;
		color: #333333;
		border-radius: 50%;
		padding: 50px;
		text-align: center;
		font-size: 2rem;
		font-weight: bold;
		width: 50px;

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

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

Random outcome will be on page refresh as following.

Functional example:

Author: Danyal
I'm skilled programmer with expertise in Vue.js/Nux.js for front-end development and PHP Laravel for back-end development. I excel in building APIs and services, and also have experience in web server setup & maintenance. My versatile skill set allows you to develop and maintain web applications effectively, from the user interface to the server-side functionality. I love coding with never ending learning attitude, thanks for visiting