palindrome and day 4.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>Dummy Title</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 5vw;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 8vw;
|
||||
}
|
||||
|
||||
#something {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 1500px;
|
||||
}
|
||||
|
||||
li {
|
||||
width: 100px;
|
||||
padding: 2vw;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Hello cruel world!</h1>
|
||||
<div id="something">
|
||||
<ul>
|
||||
<?php
|
||||
for ($i = 0; $i < 30; $i++) {
|
||||
echo "<li>Item $i</li>";
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<img src="https://images.unsplash.com/photo-1448375240586-882707db888b?fm=jpg&q=60&w=3000&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8Zm9yZXN0fGVufDB8fDB8fHww" />
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
$head = <<<EOL
|
||||
<head>
|
||||
<title>E-Commerce</title>
|
||||
<link rel="stylesheet" href="css/styles.css">
|
||||
</head>
|
||||
EOL;
|
||||
|
||||
echo $head;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
echo '<!doctype html>';
|
||||
echo '<html lang="en">';
|
||||
include('head.php');
|
||||
|
||||
echo '<body>';
|
||||
include('nav.php');
|
||||
echo '</body>';
|
||||
echo '</html>';
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$nav = <<<EOL
|
||||
<div id="nav">
|
||||
<ul id="nav-ul">
|
||||
<li id="nav-ul-li">
|
||||
<a href="#">
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li id="nav-ul-li">
|
||||
<a href="#">
|
||||
Cart
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
EOL;
|
||||
|
||||
echo $nav;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>Palindrome Tester</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Palindrome Tester</h1>
|
||||
<form action="index.php" method="[post | get]">
|
||||
<input type="text" name="input">
|
||||
<input type="submit">
|
||||
</form>
|
||||
<?php echo $output; ?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<?php
|
||||
$input = $_GET['input'];
|
||||
$sanitized_input = sanitize_input($input);
|
||||
if ($sanitized_input == strrev($sanitized_input))
|
||||
$output = '<p>Is Palindrome</p>';
|
||||
else
|
||||
$output = '<p>Is Not Palindrome</p>';
|
||||
|
||||
function sanitize_input($input)
|
||||
{
|
||||
$invalid_chars = [' ', "'", '?', '/', '\\', '.', ','];
|
||||
$output = strtolower($input);
|
||||
$output = trim($output);
|
||||
$output = str_replace($invalid_chars, '', $output);
|
||||
|
||||
return $output;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
$input = $_GET['input'];
|
||||
$sanitized_input = sanitize_input($input);
|
||||
if ($sanitized_input == strrev($sanitized_input))
|
||||
$output = '<p>Is Palindrome</p>';
|
||||
else
|
||||
$output = '<p>Is Not Palindrome</p>';
|
||||
|
||||
function sanitize_input($input)
|
||||
{
|
||||
$output = strtolower($input);
|
||||
$output = trim($output);
|
||||
$output = str_replace([',', ' '], '', $output);
|
||||
|
||||
return $output;
|
||||
}
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>Palindrome Tester</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Palindrome Tester</h1>
|
||||
<form action="palindrome.php" method="[post | get]">
|
||||
<input type="text" name="input">
|
||||
<input type="submit">
|
||||
</form>
|
||||
<?php
|
||||
echo $output;
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user