Php String Tools Web App
complete ready-to-upload PHP project for you in the canvas 👉
💡 What this project includes:
- ✅ String tools (uppercase, lowercase, reverse, etc.)
- ✅ Slug generator (SEO useful for your site)
- ✅ Email masking (real-world feature)
- ✅ Word counter
- ✅ Clean UI (simple + fast)
- ✅ Security using
htmlspecialchars()
<?php
// Simple PHP String Tools Web App
// Upload this file as index.php on your server
$result = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$input = $_POST['text'] ?? '';
$action = $_POST['action'] ?? '';
switch ($action) {
case 'uppercase':
$result = strtoupper($input);
break;
case 'lowercase':
$result = strtolower($input);
break;
case 'reverse':
$result = strrev($input);
break;
case 'length':
$result = "Length: " . strlen($input);
break;
case 'slug':
$slug = strtolower($input);
$slug = preg_replace("/[^a-z0-9]+/", "-", $slug);
$slug = trim($slug, "-");
$result = $slug;
break;
case 'word_count':
$result = "Words: " . str_word_count($input);
break;
case 'remove_spaces':
$result = str_replace(" ", "", $input);
break;
case 'email_mask':
if (strpos($input, '@') !== false) {
$pos = strpos($input, '@');
$result = substr($input, 0, 1) . "***" . substr($input, $pos);
} else {
$result = "Invalid Email";
}
break;
default:
$result = "Invalid action";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PHP String Tools | SOA Technology</title>
<style>
body { font-family: Arial; background:#f4f4f4; padding:20px; }
.container { max-width:600px; margin:auto; background:#fff; padding:20px; border-radius:10px; box-shadow:0 0 10px rgba(0,0,0,0.1);}
h1 { text-align:center; }
textarea { width:100%; height:100px; margin-bottom:10px; padding:10px; }
select, button { width:100%; padding:10px; margin-bottom:10px; }
.result { background:#e8f5e9; padding:10px; border-radius:5px; }
</style>
</head>
<body>
<div class="container">
<h1>PHP String Tools</h1>
<form method="POST">
<textarea name="text" placeholder="Enter your text here..." required></textarea>
<select name="action" required>
<option value="">Select Action</option>
<option value="uppercase">Uppercase</option>
<option value="lowercase">Lowercase</option>
<option value="reverse">Reverse String</option>
<option value="length">String Length</option>
<option value="slug">Generate Slug</option>
<option value="word_count">Word Count</option>
<option value="remove_spaces">Remove Spaces</option>
<option value="email_mask">Mask Email</option>
</select>
<button type="submit">Process</button>
</form>
<?php if ($result !== ""): ?>
<div class="result">
<strong>Result:</strong><br>
<?php echo htmlspecialchars($result); ?>
</div>
<?php endif; ?>
</div>
</body>
</html>






