How to Create Cosine Calculator using PHP with Example?

Hello Friends Today, through this tutorial, I will tell you How to Write Program Cosine calculator using PHP with HTML. Sure! Here’s a simple example of a cosine calculator using PHP with HTML:

index.php

<!DOCTYPE html>
<html>
<head>
<title>Cosine Calculator</title>
</head>
<body>
<h2>Cosine Calculator</h2>
<form method="post" action="">
Enter an angle in degrees: <input type="text" name="angle" required><br><br>
<input type="submit" name="submit" value="Calculate">
</form>

<?php
// Function to calculate cosine
function cosine($angle) {
return cos(deg2rad($angle));
}

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

// Retrieve angle from form input
$angle = $_POST["angle"];

// Validate input
if (!is_numeric($angle)) {
echo "Please enter a valid number.";
} else {

// Calculate cosine
$result = cosine($angle);
echo "Cosine of $angle degrees is: $result";
}
}
?>
</body>
</html>

This code creates a simple HTML form where users can input an angle in degrees. When the form is submitted, the PHP code calculates the cosine of the entered angle and displays the result below the form. The `cosine()` function takes an angle in degrees as input and returns its cosine. The `deg2rad()` function is used to convert degrees to radians, as the `cos()` function in PHP expects angles to be in radians.

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.