Word Count Calculator Create Using PHP with HTML

Hello Friends Today, through this tutorial, I will tell you How to Write Program word counter calculator using PHP with HTML? Below is a simple Word Count Calculator created using PHP with HTML:

index.php

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Word Count Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
label {
display: block;
margin-bottom: 8px;
}
input {
width: 100%;
padding: 8px;
margin-bottom: 16px;
box-sizing: border-box;
}
button {
background-color: #4CAF50;
color: white;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
p {
margin-top: 20px;
}
</style>
</head>
<body>
<h2>Word Count Calculator</h2>
<form action="" method="post">
<label for="text">Enter Text:</label>
<textarea id="text" name="text" rows="5" placeholder="Enter text"></textarea>
<button type="submit">Count Words</button>
</form>

<?php
// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {

// Retrieve the input text
$text = $_POST['text'];

// Count the number of words
$wordCount = str_word_count($text);

// Display the result
echo "<p>Total Words: $wordCount</p>";

}
?>
</body>
</html>

This HTML file includes a form with a textarea for entering text and a button to submit the form. Upon submission, the form data is sent to the same page (`$_SERVER[“REQUEST_METHOD”] == “POST”`). In the PHP section, it retrieves the text from the form data, counts the number of words using `str_word_count()` function, and then displays the word count.

Cialis (Tadalafil) är den främsta konkurrenten till Viagra (Sildenafil) på marknaden för erektil dysfunktion. köpa Cialis i Sverige föredras av många på grund av sin längre varaktighet och anses vara det mest kostnadseffektiva varumärkesbaserade ED-läkemedlet som finns tillgängligt i Sverige. Cialis finns i två varianter: Cialis och Cialis Daily, och fyra olika doseringar: 2,5 mg, 5 mg, 10 mg och 20 mg, erbjuder Cialis också en rad olika alternativ för att passa patientens behov.