From 836d667774bd3c44d21aaa4bf3db194e08007cfe Mon Sep 17 00:00:00 2001 From: Sofia Romera Date: Fri, 20 May 2022 20:51:48 +0200 Subject: [PATCH] Finished pill --- Functionalities/arrays.php | 54 ++++++++++++++++++++++ Functionalities/conditionals.php | 69 ++++++++++++++++++++++++++++ Functionalities/dates.php | 28 ++++++++++++ Functionalities/functions.php | 50 ++++++++++++++++++++ Functionalities/iterators.php | 49 ++++++++++++++++++++ Functionalities/maths.php | 41 +++++++++++++++++ Functionalities/operators.php | 78 ++++++++++++++++++++++++++++++++ Functionalities/phpinfo.php | 17 +++++++ Functionalities/print.php | 25 ++++++++++ Functionalities/strings.php | 72 +++++++++++++++++++++++++++++ Functionalities/types.php | 58 ++++++++++++++++++++++++ 11 files changed, 541 insertions(+) create mode 100644 Functionalities/arrays.php create mode 100644 Functionalities/conditionals.php create mode 100644 Functionalities/dates.php create mode 100644 Functionalities/functions.php create mode 100644 Functionalities/iterators.php create mode 100644 Functionalities/maths.php create mode 100644 Functionalities/operators.php create mode 100644 Functionalities/phpinfo.php create mode 100644 Functionalities/print.php create mode 100644 Functionalities/strings.php create mode 100644 Functionalities/types.php diff --git a/Functionalities/arrays.php b/Functionalities/arrays.php new file mode 100644 index 0000000..ecb352d --- /dev/null +++ b/Functionalities/arrays.php @@ -0,0 +1,54 @@ + + + + + + + Arrays + + + + '; + + $simpleArray2 = array(11, 30, 30.15, 1.14159265); + var_dump($simpleArray2); + echo '
'; + + $bts = array( + array('RM'), + array('Jin'), + array('Taehyung'), + array('Jimin'), + array('Suga'), + array('J-Hope'), + array('Jungkook') + ); + var_dump($bts); + echo '
'; + + echo count($simpleArray); + echo '
'; + + $comb = array_merge($simpleArray, $bts); + var_dump($comb); + echo '
'; + + $pushArray = array('Rose Quartz, Amethyst', 'Tiger Eye'); + array_push($pushArray, 'Citrine'); + var_dump($pushArray); + + ?> + + + \ No newline at end of file diff --git a/Functionalities/conditionals.php b/Functionalities/conditionals.php new file mode 100644 index 0000000..dbfe499 --- /dev/null +++ b/Functionalities/conditionals.php @@ -0,0 +1,69 @@ + + + + + + + Conditionals + + + +
'; + + if (date('M') == "Oct"){ + echo "We are on October!!"; + }else{ + echo date('M'); + } + + echo '

'; + + if(date('i') < 10){ + echo "the current minute is less than 10"; + }elseif (date('i') > 15) { + echo "the current minute is more than 15"; + }else { + echo "does not meet any conditions"; + } + + echo "
"; + echo "
"; + + $dt = date('D'); + switch ($dt) { + case "Mon": + echo "Today is: $dt"; + break; + case "Tue": + echo "Today is: $dt"; + break; + case "Wed": + echo "Today is: $dt"; + break; + case "Thu": + echo "Today is: $dt"; + break; + case "Fri": + echo "Today is: $dt"; + break; + case "Sat": + echo "Today is: $dt"; + break; + case "Sun": + echo "Today is: $dt"; + break; + } + ?> + + \ No newline at end of file diff --git a/Functionalities/dates.php b/Functionalities/dates.php new file mode 100644 index 0000000..2df63b9 --- /dev/null +++ b/Functionalities/dates.php @@ -0,0 +1,28 @@ + + + + + + + Date + + + + "; + echo "Today is " . date("d") . "
"; + echo "Month is: " . intval(date("m")) . "
"; //intval to remove the zero + echo "Today is " . date("l") . "
"; + echo "Time: " . date("h:i:s") . "
"; + echo "Minute: " . date("i"); + + ?> + + \ No newline at end of file diff --git a/Functionalities/functions.php b/Functionalities/functions.php new file mode 100644 index 0000000..2ad0a14 --- /dev/null +++ b/Functionalities/functions.php @@ -0,0 +1,50 @@ + + + + + + + Functions + + + + '; + + function mult($a, $b) { + echo $a * $b; + } + mult(3, 2); + echo '
'; + + function divs($a, $b) { + echo $a / $b; + } + divs(6, 2); + echo '
'; + + function op($a, $op, $b ){ + if ($op == "+") { + return $a + $b; + }elseif ($op == "*") { + return $a * $b; + }else if ($op == "/") { + return $a / $b; + } + } + echo op(2, '*', 9); + + ?> + + \ No newline at end of file diff --git a/Functionalities/iterators.php b/Functionalities/iterators.php new file mode 100644 index 0000000..bd423d2 --- /dev/null +++ b/Functionalities/iterators.php @@ -0,0 +1,49 @@ + + + + + + + Iterators + + + + * $i"; + } + + echo '
'; + echo '
'; + + $nums = array('1', '2', '3', '4', '5'); + foreach ($nums as $value) { + echo $value * 2; + } + + echo '
'; + echo '
'; + + $noms = array('pear', 'banana', 'apple'); + foreach ($noms as $key) { + echo $key.' is a fruit'.'
'; + } + echo "
"; + $i = 0; + while ($i <= 10) { + echo "Num is: $i
"; + $i++; + } + + do{ + echo "$i
"; + } while ($i < 10); + ?> + + + \ No newline at end of file diff --git a/Functionalities/maths.php b/Functionalities/maths.php new file mode 100644 index 0000000..95d677a --- /dev/null +++ b/Functionalities/maths.php @@ -0,0 +1,41 @@ + + + + + + + Maths + + + + '; + + $b = ceil(3.14159265); + echo $b; + echo '
'; + + $c = max(2, 4, 9, 25, 6, 98, 3); + echo $c; + echo '
'; + + $d = min(2, 4, 9, 25, 6, 98, 3); + echo $d; + echo '
'; + + $e = rand(1, 100); + echo $e; + echo '
'; + + ?> + + + \ No newline at end of file diff --git a/Functionalities/operators.php b/Functionalities/operators.php new file mode 100644 index 0000000..bbd8185 --- /dev/null +++ b/Functionalities/operators.php @@ -0,0 +1,78 @@ + + + + + + + Operators + + + + '; + echo '-------'; + echo '
'; + + echo ($a + $b); + echo '
'; + var_dump ($a - $b); + echo '
'; + var_dump ($a * $b); + echo '
'; + var_dump (intdiv($a , $b)); + echo '
'; + var_dump ($a % $b); + echo '
'; + + echo '
'; + echo '-------'; + echo '
'; + + //Comparison operators + + echo ($a == $b); + echo '
'; + var_dump ($a != $b); + echo '
'; + var_dump ($a < $b); + echo '
'; + var_dump ($a > $b); + echo '
'; + var_dump ($a <= $b); + echo '
'; + var_dump ($a >= $b); + echo '
'; + + + echo '
'; + echo '-------'; + echo '
'; + + //Logical operators + var_dump ($a && $b); + echo '
'; + var_dump ($a and $b); + echo '
'; + var_dump ($a || $b); + echo '
'; + var_dump ($a or $b); + echo '
'; + var_dump (! $b); + echo '
'; + var_dump ($a Xor $b); + echo '
'; + + ?> + + \ No newline at end of file diff --git a/Functionalities/phpinfo.php b/Functionalities/phpinfo.php new file mode 100644 index 0000000..5baf9fa --- /dev/null +++ b/Functionalities/phpinfo.php @@ -0,0 +1,17 @@ + + + + + + + PHP info + + + + + + \ No newline at end of file diff --git a/Functionalities/print.php b/Functionalities/print.php new file mode 100644 index 0000000..a378cee --- /dev/null +++ b/Functionalities/print.php @@ -0,0 +1,25 @@ + + + + + + + Print PHP + + + + "; + print "World"; + echo "
"; + $arrayName = array("Peter" => "35", "Ben" => "37", "Joe" => array ('43', '180 cm'));; + print_r ($arrayName); + ?> + + + \ No newline at end of file diff --git a/Functionalities/strings.php b/Functionalities/strings.php new file mode 100644 index 0000000..ac91c5f --- /dev/null +++ b/Functionalities/strings.php @@ -0,0 +1,72 @@ + + + + + + + Strings + + + + '; + + $txt2 = "Monday"; + print "Today is $txt2"; + echo '
'; + + $sat = 'saturday'; + print 'My favorite day of the week is '.$sat; + echo '
'; + + $wrong = "lorem ipsum doler sit amet"; + echo str_replace('doler', 'dolor', $wrong); + echo '
'; + + $wrong2 = "lorem ipsum doler sit amet"; + echo str_replace('DOLER', 'dolor', $wrong2); + echo '
'; + + $repeatString = "Hyoyeon, "; + echo str_repeat($repeatString, 3); + echo "
"; + + $strLen = "Badster by Hyoyeon"; + echo strlen($strLen); + echo '
'; + + $firstOcc = "Alattsa ttsa yari bidabiri ra baritz Ddan din dan den dan doo"; + echo strpos($firstOcc, "yari"); + echo "
"; + + $upperCase = "Aespa"; + echo strtoupper($upperCase); + echo '
'; + + $lowerCase = "R.tee X Anda"; + echo strtolower($lowerCase); + echo '
'; + + $str = "Wa bali ttattaa Pari parii ladi bidi bidibidi Sutan den dan doo"; + echo substr($str, 15); + + ?> + + + \ No newline at end of file diff --git a/Functionalities/types.php b/Functionalities/types.php new file mode 100644 index 0000000..c2111d6 --- /dev/null +++ b/Functionalities/types.php @@ -0,0 +1,58 @@ + + + + + + + Types + + + + '; + echo '
'; + $a = 1234; //integer + var_dump ($a); + echo '

'; + $b = 1.234; //float + var_dump ($b); + echo '

'; + $str = 'this is a simple string'; //string + var_dump ($str); + echo '

'; + $array = array( + 1 => "a", + "1" => "b", + 1.5 => "c", + true => "d", + ); + var_dump($array); + echo '

'; + //↓↓Objects + $obj = new stdClass(); + $obj -> name = "Nick"; + $obj -> surname = "Doe"; + var_dump($obj); + echo '

'; + $object = (object) [ + 'propertyOne' => 'foo', + 'propertyTwo' => 42, + ]; + var_dump($object); + //-------- + $ab = NULL; + var_dump ($ab); + ?> + + \ No newline at end of file