aboutsummaryrefslogtreecommitdiff
path: root/Web design/PHP
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2020-06-28 10:26:03 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2020-06-28 10:26:03 +0300
commit6f4cfe7b5c6c74d83b03e18870aeb6977db6c0de (patch)
tree11f667f63e10fee036cd963dde35562183b9764d /Web design/PHP
parentf2d1216153123a3fbee6af8e7a0ad06a3577f216 (diff)
downloadSelf-learning-6f4cfe7b5c6c74d83b03e18870aeb6977db6c0de.tar
Self-learning-6f4cfe7b5c6c74d83b03e18870aeb6977db6c0de.tar.gz
Self-learning-6f4cfe7b5c6c74d83b03e18870aeb6977db6c0de.zip
Did some tinkering with PHP and Javascript.
Diffstat (limited to 'Web design/PHP')
-rw-r--r--Web design/PHP/Test/calc.php17
-rw-r--r--Web design/PHP/Test/footer.html1
-rw-r--r--Web design/PHP/Test/header.php3
-rw-r--r--Web design/PHP/Test/index.php155
-rw-r--r--Web design/PHP/Test/process.php13
5 files changed, 189 insertions, 0 deletions
diff --git a/Web design/PHP/Test/calc.php b/Web design/PHP/Test/calc.php
new file mode 100644
index 0000000..c2728d9
--- /dev/null
+++ b/Web design/PHP/Test/calc.php
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="" dir="ltr">
+ <head>
+ <meta charset="utf-8">
+ <title></title>
+ </head>
+ <body>
+ <?php
+ if ($_POST["one"]) {
+ echo 1;
+ }
+ elseif ($_POST["two"]) {
+ echo 2;
+ }
+ ?>
+ </body>
+</html>
diff --git a/Web design/PHP/Test/footer.html b/Web design/PHP/Test/footer.html
new file mode 100644
index 0000000..9d5e5c6
--- /dev/null
+++ b/Web design/PHP/Test/footer.html
@@ -0,0 +1 @@
+<p>Subscribe</p>
diff --git a/Web design/PHP/Test/header.php b/Web design/PHP/Test/header.php
new file mode 100644
index 0000000..73c6301
--- /dev/null
+++ b/Web design/PHP/Test/header.php
@@ -0,0 +1,3 @@
+<?php
+ echo "Subscribe to $name";
+?>
diff --git a/Web design/PHP/Test/index.php b/Web design/PHP/Test/index.php
new file mode 100644
index 0000000..00e4125
--- /dev/null
+++ b/Web design/PHP/Test/index.php
@@ -0,0 +1,155 @@
+<!DOCTYPE html>
+<html lang="en" dir="ltr">
+ <head>
+ <meta charset="utf-8">
+ <title></title>
+ </head>
+ <body>
+ <?php
+ $name = "John";
+ include "header.php";
+ ?>
+ <br>
+ <?php
+ $loggedin = false;
+
+ if ($loggedin) {
+ echo "Hello";
+ }
+ else {
+ echo "Please log in";
+ }
+ ?>
+
+ <form class="" action="process.php" method="post">
+ Enter your name: <input type="text" name="name" value="">
+ <input type="submit" name="" value="Submit">
+ </form>
+
+ <?php
+ function doStuff($workers) {
+ echo "First worker: " . strtolower($workers[0]) . strlen($workers[0]) . " " . strtoupper($workers[1]) . $workers[0][0] . " <br>";
+ echo str_replace("Jo", "Mo", $workers[0]) . "<br>";
+ echo substr($workers[0], 1, 1) . "<br>";
+ }
+
+ $staff = array("John", "Bob");
+ doStuff($staff);
+
+ foreach ($workers as $person) {
+ echo $person . ", ";
+ }
+ ?>
+
+ <br>
+
+ <?php
+ $numbers = array(1, 2, 3, 4);
+ $sum = 0;
+
+ foreach($numbers as $num) {
+ $sum += $num;
+ }
+ echo $sum . "<br>";
+
+ $num = 0;
+ echo $num++;
+ echo $num;
+
+ $num = 0;
+ echo ++$num;
+ ?>
+
+ <br>
+
+ <h2>Calculator</h2>
+
+ <form class="" action="calc.php" method="post">
+ <label for=""></label>
+ <br>
+ <input type="submit" name="one" value="1">
+ <input type="submit" name="two" value="2">
+ <input type="submit" name="three" value="3">
+ <br>
+ <input type="button" name="four" value="4">
+ <input type="button" name="five" value="5">
+ <input type="button" name="six" value="6">
+ <br>
+ <input type="button" name="seven" value="7">
+ <input type="button" name="eight" value="8">
+ <input type="button" name="nine" value="9">
+ <br>
+ <input type="button" name="zero" value="0">
+ <br>
+ <input type="button" name="add" value="+">
+ <input type="button" name="sub" value="-">
+ <input type="button" name="mlt" value="*">
+ <input type="button" name="div" value="/">
+
+ </form>
+
+ <br>
+
+ <form class="" action="index.php" method="post">
+ Blue: <input type="checkbox" name="colors[]" value="blue"> <br>
+ Red: <input type="checkbox" name="colors[]" value="red"> <br>
+ Yellow: <input type="checkbox" name="colors[]" value="yellow"> <br>
+ <input type="submit" name="" value="Submit">
+ </form>
+
+ <?php
+ // comment
+ foreach($_POST["colors"] as $color) {
+ echo $color . " ";
+ }
+ ?>
+
+ <br>
+
+ <?php
+ $ages = array("John" => 31, "Alex" => 20);
+
+ echo $ages["John"] . $ages["Alex"];
+ ?>
+
+ <br>
+
+ <?php
+ class Person {
+ public $name;
+ private $age;
+
+ function __construct($personName, $personAge) {
+ $this->name = $personName;
+ $this->setAge($personAge);
+ }
+
+ function setAge($age) {
+ if ($age < 0 || $age > 200) {
+ throw new Exception("Invalid age!", 1);
+ }
+ $this->age = $age;
+ }
+
+ function getAge() {
+ return $this->age;
+ }
+ }
+
+ class Worker extends Person {
+
+ }
+
+ $max = new Worker("Alex", 34);
+
+ //$max->name = "Max";
+ //$max->age = 22;
+
+ echo $max->name, $max->getAge();
+ ?>
+
+ <?php
+ include "footer.html";
+ ?>
+ </body>
+</html>
diff --git a/Web design/PHP/Test/process.php b/Web design/PHP/Test/process.php
new file mode 100644
index 0000000..796b517
--- /dev/null
+++ b/Web design/PHP/Test/process.php
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en" dir="ltr">
+ <head>
+ <meta charset="utf-8">
+ <title></title>
+ </head>
+ <body>
+ <?php
+ $name = $_POST["name"];
+ echo "Hello " . $name;
+ ?>
+ </body>
+</html>