diff --git a/arrays.php b/arrays.php new file mode 100644 index 0000000..8ea7ff2 --- /dev/null +++ b/arrays.php @@ -0,0 +1,45 @@ + + + + + + + + File arrays.php + + + +⮜Go Back +

library of functionalities php

+

php arrays

+ + "; + + $simpleArrs = $simpleArrString + $simpleArrNumDec; + var_dump($simpleArrs); + echo "
"; + + echo end($simpleArrString); + echo "
"; + + array_push($simpleArrNumDec, 123, 456, 789); + print_r($simpleArrNumDec); + + ?> + + + + \ No newline at end of file diff --git a/conditionals.php b/conditionals.php new file mode 100644 index 0000000..521499d --- /dev/null +++ b/conditionals.php @@ -0,0 +1,78 @@ + + + + + + + + File conditionals.php + + + +⮜Go Back +

library of functionalities php

+

php conditionals

+ + "; + + + $month = date("F"); + + if ($month == "October") { + echo "We are in October"; + } else { + echo "We aren't in October. We are in " . $month; + } + print "
"; + + + $minute = date("i"); + + if ($minute < 10) { + echo "The current minute is less than 10"; + } else if ($minute > 15) { + echo "The current minute is more than 15"; + } else { + echo "Does not meet any conditions"; + } + print "
"; + + + $switchDay = date("l"); + + switch ($switchDay) { + case "Monday": + echo "Happy Monday"; + break; + case "Tuesday": + echo "Happy Tuesday"; + break; + case "Wednesday": + echo "Happy Wednesday"; + break; + case "Thursday": + echo "Happy Thursday"; + break; + case "Friday": + echo "Happy Friday"; + break; + case "Saturday": + echo "Happy Saturday"; + break; + case "Sunday": + echo "Happy Sunday"; + break; + } + + ?> + + + + \ No newline at end of file diff --git a/dates.php b/dates.php new file mode 100644 index 0000000..b94b9da --- /dev/null +++ b/dates.php @@ -0,0 +1,39 @@ + + + + + + + + File dates.php + + + + ⮜Go Back +

library of functionalities php

+

php DateTime class

+ + format('Y-m-d'); + echo "
"; + + echo $objDateTime->format(DateTimeInterface::COOKIE); + echo "
"; + + echo "Today is " . date("l"); + echo "
"; + + echo "Current month in numerical format " . date("m"); + echo "
"; + + echo "Current minute with leading zeros " . date("i"); + echo "
"; + + ?> + + + + \ No newline at end of file diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..5366419 --- /dev/null +++ b/functions.php @@ -0,0 +1,36 @@ + + + + + + + + File functions.php + + + +⮜Go Back +

library of functionalities php

+

php functions

+ + "; + + $mul = $first * $second; + echo "Result: " . $mul . "
"; + + $dis = $first / $second; + echo "Result: " . $dis . "
"; + + $opr = $first - $second; + echo "Result: " . $opr . "
"; + + ?> + + + + \ No newline at end of file diff --git a/iterators.php b/iterators.php new file mode 100644 index 0000000..5bf8be1 --- /dev/null +++ b/iterators.php @@ -0,0 +1,152 @@ + + + + + + + + File iterators.php + + + +⮜Go Back +

library of functionalities php

+

php iterators using "for"

+ + "; + + for ($i = 1;; $i++) { + if ($i > 10) { + break; + } + echo $i; + echo " "; + } + + echo "
"; + + $i = 1; + for (;;) { + if ($i > 10) { + break; + } + echo $i; + echo " "; + $i++; + } + + echo "
"; + + for ($i = 1, $j = 0; $i <= 10; $j += $i, print $i, print " ", $i++); + + + ?> + + + +

+

php iterators using "forEach"

+ + "; + + + $a = array(1, 2, 3, 17); + + $i = 0; + + foreach ($a as $v) { + echo "\$a[$i] => $v.\n"; + $i++; + } + echo "
"; + + + $a = array( + "uno" => 1, + "dos" => 2, + "tres" => 3, + "diecisiete" => 17 + ); + + foreach ($a as $k => $v) { + echo "\$a[$k] => $v.\n"; + } + echo "
"; + + + $a = array(); + $a[0][0] = "a"; + $a[0][1] = "b"; + $a[1][0] = "y"; + $a[1][1] = "z"; + + foreach ($a as $v1) { + foreach ($v1 as $v2) { + echo "$v2\n"; + } + } + echo "
"; + + + foreach (array(1, 2, 3, 4, 5) as $v) { + echo "$v\n"; + } + + ?> + + + +

+

php iterators using "while"

+ + "; + + + $i = 1; + while ($i <= 10) : + echo "$i\n"; + $i++; + endwhile; + + ?> + + + +

+

php iterators using "do while"

+ + "; + $i++; + } while ($i <= 5); + + ?> + + + + \ No newline at end of file diff --git a/maths.php b/maths.php new file mode 100644 index 0000000..91c1ba0 --- /dev/null +++ b/maths.php @@ -0,0 +1,50 @@ + + + + + + + + File maths.php + + + +⮜Go Back +

library of functionalities php

+

php maths

+ + + + "; + + + echo ceil(4.3) . "
"; + + + function highestValue() { + $hValue = [12,34,6,132,74,28,131,98]; + return max($hValue); + } + echo highestValue() . "
"; + + + function lowestValue() { + $lValue = [12,34,6,132,74,28,131,98]; + return min($lValue); + } + echo lowestValue() . "
"; + + + function randomValue() { + return rand(1, 10); + } + echo randomValue(); + + ?> + + + + \ No newline at end of file diff --git a/operators.php b/operators.php new file mode 100644 index 0000000..95ec456 --- /dev/null +++ b/operators.php @@ -0,0 +1,107 @@ + + + + + + + + File operators.php + + + +⮜Go Back +

library of functionalities php

+ + + +

php arithmetic operators

+ + "; + + + $b = 1; + $c = 2; + echo $b = $c += 3; + echo "
"; + + + $d = 1; + echo $d + $d++; + echo "
"; + + ?> + + + +

+

php comparison operators

+ + 1; + echo "
"; + + + echo 2.5 <=> 1.5; + echo "
"; + + + echo "b" <=> "a"; + echo "
"; + + + echo "zz" <=> "aa"; + echo "
"; + + + echo [1, 2, 3] <=> [1, 2, 4]; + echo "
"; + + + $a = (object) ["a" => "c"]; + $b = (object) ["a" => "b"]; + echo $a <=> $b; + + ?> + + + +

+

php logical operators

+ + + + + + \ No newline at end of file diff --git a/phpinfo.php b/phpinfo.php new file mode 100644 index 0000000..c880668 --- /dev/null +++ b/phpinfo.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/print.php b/print.php new file mode 100644 index 0000000..c4dfd74 --- /dev/null +++ b/print.php @@ -0,0 +1,91 @@ + + + + + + + + File print.php + + + +⮜Go Back +

library of functionalities php

+

php "echo" instructions

+ + + + + +

+

php "print" instructions

+ + + + + +

+

php "print_r" instructions

+ + 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z')); + print_r ($a); + + ?> + + + diff --git a/strings.php b/strings.php new file mode 100644 index 0000000..88f28cf --- /dev/null +++ b/strings.php @@ -0,0 +1,70 @@ + + + + + + + + File strings.php + + + +⮜Go Back +

library of functionalities php

+

php strings

+ + "; + + $var = "Printing a text string that interpret variables"; + print $var . "
"; + + $name = "Jhon"; + $age = 23; + print "The age of $name is $age
"; + + + $strictlyPhrase = "You should eat fruits, vegetables, and fiber every day."; + $strictlyHealthy = array("fruits", "vegetables", "fiber"); + $strictlyYummy = array("pizza", "chips", "ice cream"); + + $strictlyNewPhrase = str_replace($strictlyHealthy, $strictlyYummy, $strictlyPhrase); + print $strictlyNewPhrase . "
"; + + + $replacePhrase = "You should eat fruits, vegetables, and fiber every day."; + $replaceHealthy = array("fruits", "vegetables", "fiber"); + $replaceYummy = array("pizza", "chips", "ice cream"); + + $replaceNewPhrase = str_replace($replaceHealthy, $replaceYummy, $replacePhrase); + print $replaceNewPhrase . "
"; + + + $i = 1; + while ($i <= 6) : + echo "This text will repeat it self
"; + $i++; + endwhile; + + + $textString = "awesome"; + echo "Awesome has " . strlen($textString) . " characters.
"; + + + $mystring = 'abcdefg'; + $findme = 'e'; + $pos = strpos($mystring, $findme); + echo $pos . "
"; + + echo ucfirst("hello everyone") . "
"; + + echo strtolower("I'm LOVING It to CODE") . "
"; + + echo substr("abcdef", 2, -1) . " from abcdef"; + + ?> + + + + \ No newline at end of file diff --git a/types.php b/types.php new file mode 100644 index 0000000..7f10577 --- /dev/null +++ b/types.php @@ -0,0 +1,58 @@ + + + + + + + + File types.php + + + +⮜Go Back +

library of functionalities php

+

php types

+ + + + "; + + $million = 1000000; + $integer = 50000000000000 * $million; + var_dump($integer); + echo "
"; + + + $a = "1234.56789"; + echo floatval($a) . "
"; + + + echo 'Arnold once said: "I\'ll be back"' . "
"; + + + $array = array( + 1 => "a", + "1" => "b", + 1.5 => "c", + true => "d", + ); + var_dump($array); + echo "
"; + + + $obj = (object) array('1' => 'foo'); + var_dump(isset($obj->{'1'})); + echo "
"; + + + $var = NULL; + echo "\$var = null;" + + ?> + + + + \ No newline at end of file