From 4725482d00e691524b0b64927c7fbd9e2d812794 Mon Sep 17 00:00:00 2001 From: Iuliia Shikhanova Date: Mon, 19 Dec 2022 12:58:55 +0000 Subject: [PATCH 01/11] first commit --- arrays.php | 0 conditionals.php | 0 dates.php | 0 functions.php | 0 iterators.php | 0 maths.php | 0 operators.php | 0 phpinfo.php | 3 +++ print.php | 0 strings.php | 0 types.php | 0 11 files changed, 3 insertions(+) create mode 100644 arrays.php create mode 100644 conditionals.php create mode 100644 dates.php create mode 100644 functions.php create mode 100644 iterators.php create mode 100644 maths.php create mode 100644 operators.php create mode 100644 phpinfo.php create mode 100644 print.php create mode 100644 strings.php create mode 100644 types.php diff --git a/arrays.php b/arrays.php new file mode 100644 index 0000000..e69de29 diff --git a/conditionals.php b/conditionals.php new file mode 100644 index 0000000..e69de29 diff --git a/dates.php b/dates.php new file mode 100644 index 0000000..e69de29 diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..e69de29 diff --git a/iterators.php b/iterators.php new file mode 100644 index 0000000..e69de29 diff --git a/maths.php b/maths.php new file mode 100644 index 0000000..e69de29 diff --git a/operators.php b/operators.php new file mode 100644 index 0000000..e69de29 diff --git a/phpinfo.php b/phpinfo.php new file mode 100644 index 0000000..5299cc6 --- /dev/null +++ b/phpinfo.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/print.php b/print.php new file mode 100644 index 0000000..e69de29 diff --git a/strings.php b/strings.php new file mode 100644 index 0000000..e69de29 diff --git a/types.php b/types.php new file mode 100644 index 0000000..e69de29 From 4cc8e247921dd4ef8e6d0a4f1c0a337297806f08 Mon Sep 17 00:00:00 2001 From: Iuliia Shikhanova Date: Mon, 19 Dec 2022 13:03:55 +0000 Subject: [PATCH 02/11] push files --- phpinfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpinfo.php b/phpinfo.php index 5299cc6..5b63fb8 100644 --- a/phpinfo.php +++ b/phpinfo.php @@ -1,3 +1,3 @@ \ No newline at end of file +?> From 2d4a6d28303821c1c8acdc1d4ad5ef0dbb6736e2 Mon Sep 17 00:00:00 2001 From: Iuliia Shikhanova Date: Mon, 19 Dec 2022 16:48:15 +0000 Subject: [PATCH 03/11] types, iterators, phpinfo, print, functions --- arrays.php | 13 +++++++++++ conditionals.php | 3 +++ dates.php | 12 ++++++++++ functions.php | 28 ++++++++++++++++++++++ iterators.php | 36 ++++++++++++++++++++++++++++ maths.php | 3 +++ operators.php | 3 +++ phpinfo.php | 2 +- print.php | 22 +++++++++++++++++ strings.php | 3 +++ types.php | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 185 insertions(+), 1 deletion(-) diff --git a/arrays.php b/arrays.php index e69de29..59313d3 100644 --- a/arrays.php +++ b/arrays.php @@ -0,0 +1,13 @@ + + + + +Define a simple array composed of text strings +Define a simple array consisting of whole numbers and decimal numbers +Define a multidimensional array +Execute the function that allows to obtain the length of an array +Execute the function that allows to obtain the combination of two arrays +Execute the function that once is given an array return the last element of it +Execute the function that once is given an array add a new element to the array in question diff --git a/conditionals.php b/conditionals.php index e69de29..15c5adc 100644 --- a/conditionals.php +++ b/conditionals.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/dates.php b/dates.php index e69de29..f9240df 100644 --- a/dates.php +++ b/dates.php @@ -0,0 +1,12 @@ + + +Instance the Date Time class and then invoke the format method with the argument “Y-m-d” to show year-month-day +Get the current date in any format +Get the current day +Get the current month in numerical format (1-12) +Get the current minute with leading zeros (00 - 59) diff --git a/functions.php b/functions.php index e69de29..10b052f 100644 --- a/functions.php +++ b/functions.php @@ -0,0 +1,28 @@ +
"; + +function multOfBoth(int $a, int $b){ + return $a * $b; +} +echo multOfBoth(10,7); +echo "

"; + +function divOfBoth(int $a, int $b){ + return $a / $b; +} +echo divOfBoth(70,7); +echo "

"; + + +function all(int $a,int $b, int $c, int $d){ + return $a + $b * $c / $d; +} +echo all(70, 7, 8, 6); +echo "

"; +?> + diff --git a/iterators.php b/iterators.php index e69de29..2df19ed 100644 --- a/iterators.php +++ b/iterators.php @@ -0,0 +1,36 @@ +
"; + +// For + +$i = 0; +for ($i=0; $i < 10; $i++){ + echo $i; + } + echo "

"; + +// While +$y = 0; +while ($y < 10){ + $y++; + echo "While: $y"; +} +echo "

"; + +// Do-while que imprime 012345678910 +$x = 0; +do{ + $x++; + echo "Do-While: $x"; + } while ($x<10); + +?> \ No newline at end of file diff --git a/maths.php b/maths.php index e69de29..15c5adc 100644 --- a/maths.php +++ b/maths.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/operators.php b/operators.php index e69de29..15c5adc 100644 --- a/operators.php +++ b/operators.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/phpinfo.php b/phpinfo.php index 5b63fb8..5299cc6 100644 --- a/phpinfo.php +++ b/phpinfo.php @@ -1,3 +1,3 @@ +?> \ No newline at end of file diff --git a/print.php b/print.php index e69de29..e9f2eee 100644 --- a/print.php +++ b/print.php @@ -0,0 +1,22 @@ + Mi codigo PHP - print "; + +//Echo permite imprimir varios resultadoe + +echo "

Mi primer codigo PHP - echo

", "

Mi segundo codigo PHP - echo

"; + +// imprimen los detalles de una variable + +$letKnow = array( 5, 0.0, "Hola", false, '' ); +print_r($letKnow); +echo "

"; + +// imprimen los detalles de una variable con el typo de datos + +var_dump($letKnow); + +?> + diff --git a/strings.php b/strings.php index e69de29..15c5adc 100644 --- a/strings.php +++ b/strings.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/types.php b/types.php index e69de29..82f504b 100644 --- a/types.php +++ b/types.php @@ -0,0 +1,61 @@ +
"; + +#Integer + +$numero = 25; +echo "Esto es variable integer: $numero"; +echo "

"; + +#Float + +$numeroFloat = 25.67; +echo "Esto es variable float: $numeroFloat"; +echo "

"; + + +#NULL + +$myNull = null; +echo "Esto es variable NULL: $myNull"; +echo "

"; + + +#Variavle boolean +$boleanaOne = true; +echo "Esto es boleana true: $boleanaOne"; +echo "

"; + +$boleanaTwo = false; +echo "Esto es boleana false: $boleanaTwo"; +echo "

"; + +#Array + +$colores = array("red", "blue", "green"); +echo "Esto es array: $colores[0]"; +echo "

"; +print_r ($colores); +echo "

"; + +#Objeto + +$frutas = (object)["fruta1"=>"pera", "fruta2"=>"platano", "fruta3"=>"manzana"]; +echo "Esto es un variable-objeto: $frutas->fruta2"; +echo "

"; + +?> + + + + + + + + + From 76481f29bec8142891eb472b6018db0ab362499f Mon Sep 17 00:00:00 2001 From: Iuliia Shikhanova Date: Tue, 20 Dec 2022 09:33:41 +0000 Subject: [PATCH 04/11] op --- operators.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/operators.php b/operators.php index 15c5adc..782eb8f 100644 --- a/operators.php +++ b/operators.php @@ -1,3 +1,39 @@
"; + +function multOfBoth(int $a, int $b){ + return $a * $b; +} +echo multOfBoth(10,7); +echo "

"; + +function divOfBoth(int $a, int $b){ + return $a / $b; +} +echo divOfBoth(70,7); +echo "

"; + +function divOfBoth(int $a, int $b){ + return $a % $b; +} +echo divOfBoth(70,7); +echo "

"; + +// comparison operators + +if($a < $b || $a <= $b){ + return -1; +}elseif ($a > $b && $a => $b){ + return 1; +}elseif ($a == $b){ + return 0; +}elseif($a != $b){ + return $a +} ?> \ No newline at end of file From ec79f342a55e81eeecf5674ef637510ad19c4f31 Mon Sep 17 00:00:00 2001 From: Iuliia Shikhanova Date: Tue, 20 Dec 2022 12:55:33 +0000 Subject: [PATCH 05/11] tasks --- arrays.php | 34 +++++++++++++++++++------ conditionals.php | 44 +++++++++++++++++++++++++++++++++ dates.php | 32 +++++++++++++++++------- maths.php | 38 +++++++++++++++++++++++++++- operators.php | 22 +++++++++++------ strings.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 209 insertions(+), 25 deletions(-) diff --git a/arrays.php b/arrays.php index 59313d3..4f9a7c5 100644 --- a/arrays.php +++ b/arrays.php @@ -1,13 +1,31 @@ +#multidimensional array +$cars = array ( + array("Volvo",22,18), + array("BMW",15,13), + array("Saab",5,2), + array("Land Rover",17,15) + ); + echo "

"; + #obtain the length of an array + var_dump(count($cars)); + + #combination of two arrays + + $result = array_combine($nombres, $numbers); + print_r($result); + echo "

"; + #Execute the function that once is given an array return the last element of it + echo end($nombres); + echo "

"; -Define a simple array composed of text strings -Define a simple array consisting of whole numbers and decimal numbers -Define a multidimensional array -Execute the function that allows to obtain the length of an array -Execute the function that allows to obtain the combination of two arrays -Execute the function that once is given an array return the last element of it -Execute the function that once is given an array add a new element to the array in question +#Execute the function that once is given an array add a new element to the array in question + + array_push($nombres, "Olga", "Katy"); + print_r($nombres); +?> diff --git a/conditionals.php b/conditionals.php index 15c5adc..291dda4 100644 --- a/conditionals.php +++ b/conditionals.php @@ -1,3 +1,47 @@
"; +}else echo "We are not on Monday

"; + +if($month == "October"){ + echo "We are in October

"; +}else echo "We are in " . date("F") . "

"; + +// Doble condition + +$minute = 9; +if($minute < 10){ + echo "the current minute is less than 10

"; +}elseif($minute>15){ + echo "the current minute is more than 15"; +}else echo "does not meet any conditions"; + +// Switch +$today = "friday"; + +switch($today){ + case 'Monday': + echo "Let start the week

"; + break; + + case 'Wednesday': + echo "The are just three days more to finish the week!

"; + break; + + case 'friday': + echo "The last working day

"; + break; + + case 'Sunday': + echo "Tomorrow we will start again

"; + break; + + default: echo "nothing to do"; +} + + ?> \ No newline at end of file diff --git a/dates.php b/dates.php index f9240df..c79e7e5 100644 --- a/dates.php +++ b/dates.php @@ -1,12 +1,26 @@ setDate(2022, 12, 20) + ->setTime(12, 00) + ->setTimezone(new DateTimeZone('America/New_York')) + ->format("Y-m-d\\TH:i:sP"); +echo "

"; + +// date +echo "Today is " . date("Y-m-d") . "
"; + +// day +echo "Today is " . date("l") . "
"; + +//month in numerical format (1-12) +echo "Today is " . date("m") . "
"; + +//current minute with leading zeros (00 - 59) +echo "Now is " . date("i") . "
"; + ?> -Instance the Date Time class and then invoke the format method with the argument “Y-m-d” to show year-month-day -Get the current date in any format -Get the current day -Get the current month in numerical format (1-12) -Get the current minute with leading zeros (00 - 59) + + + diff --git a/maths.php b/maths.php index 15c5adc..3bb2c8f 100644 --- a/maths.php +++ b/maths.php @@ -1,3 +1,39 @@
"; +var_dump(abs(5)); +echo"

"; +var_dump(abs(-5)); +echo"

"; + +//Define a variable whose value is the result of the function that returns a rounded value to the next highest integer. + +echo ceil(4.3); // 5 +echo"

"; +echo ceil(9.999); // 10 +echo"

"; +echo ceil(-3.14); +echo"

"; + +//Define a variable whose value is the result of the function that returns the highest value of a series of values ​​that are received by parameter. +echo max(2, 3, 1, 6, 7); +echo"

"; +echo max(array(2, 4, 5)); +echo"

"; + +//Define a variable whose value is the result of the function that returns the lowest value of a series of values ​​that are received by parameter. +echo min(2, 3, 1, 6, 7); +echo"

"; +echo min(array(2, 4, 5)); +echo"

"; + +//Define a variable whose value is the result of the function that returns a random number +echo rand() . "\n"; +echo rand() . "\n"; +echo rand(5, 15); +echo"

"; + +?> -?> \ No newline at end of file diff --git a/operators.php b/operators.php index 782eb8f..4b1face 100644 --- a/operators.php +++ b/operators.php @@ -18,22 +18,30 @@ function divOfBoth(int $a, int $b){ echo divOfBoth(70,7); echo "

"; -function divOfBoth(int $a, int $b){ +function prOfBoth(int $a, int $b){ return $a % $b; } -echo divOfBoth(70,7); +echo prOfBoth(70,7); echo "

"; -// comparison operators +// Create a usage example for comparison operators: ==,! =, <,>, <=,> = +$a = 4; +$b = 3; -if($a < $b || $a <= $b){ +if($a < $b){ return -1; -}elseif ($a > $b && $a => $b){ +}elseif ($a > $b){ return 1; }elseif ($a == $b){ return 0; }elseif($a != $b){ - return $a + return $a; } -?> \ No newline at end of file +// Create an example of use for logical operators: &&, And; ||, Or; ! (NOT); Xor + + +?> + + + diff --git a/strings.php b/strings.php index 15c5adc..3d9d8bf 100644 --- a/strings.php +++ b/strings.php @@ -1,3 +1,67 @@
'; + +$name = 'Iuliia'; + +echo "My name is $name"; +echo "

"; + +// Concatenate a previously declared variable in a text string + +$a = "Hello "; +$b = $a . "World!"; // now $b contains "Hello World!" +$a .= "World!"; +echo "$a"; +echo "

"; + + +//Execute the function that allows you to replace text in a string + +// Provides: You should eat pizza, beer, and ice cream every day +$phrase = "You should eat fruits, vegetables, and fiber every day."; +$healthy = array("fruits", "vegetables", "fiber"); +$yummy = array("pizza", "beer", "ice cream"); + +$newphrase = str_replace($healthy, $yummy, $phrase); + +echo "$newphrase"; +echo "

"; + + +//Execute the function that allows you to write a text N times + +echo str_repeat("Say Hi ", 5); +echo "

"; + +//Execute the function that allows to obtain the length of a text string +$howLong = 'Hola Iuliia'; +echo strlen($howLong); +echo "

"; + +//Executes the function that allows to obtain the position of the first occurrence of a text within a text string + +echo strpos("I love php, I love php too!","love"); +echo "

"; + +//Execute the function that allows a text string to be capitalized +$hola = "Mary Had A Little Lamb and She LOVED It So"; +$hola = strtoupper($hola); +echo $hola; +echo "

"; + +// Execute the function that allows you to transform a text string to lowercase + +$adios = "Mary Had A Little Lamb and She LOVED It So"; +$adios = strtolower($adios); +echo $adios; +echo "

"; + +// Execute the function that allows to obtain a text substring from a given position +$rest = substr("abcdef", -1); // returns "f" +$rest = substr("abcdef", 2); +echo "$rest"; + +echo "

"; + ?> \ No newline at end of file From 424b2ca777c774bc2850b09b1a0246c17460eb8f Mon Sep 17 00:00:00 2001 From: Iuliia Shikhanova Date: Tue, 20 Dec 2022 13:31:08 +0000 Subject: [PATCH 06/11] finish --- functions.php | 9 +++++++ operators.php | 71 +++++++++++++++++++++++++++++---------------------- 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/functions.php b/functions.php index 10b052f..9ad84a7 100644 --- a/functions.php +++ b/functions.php @@ -24,5 +24,14 @@ function all(int $a,int $b, int $c, int $d){ } echo all(70, 7, 8, 6); echo "

"; + + +$x=100; +$y=60; +echo "The sum of x and y is : ". ($x+$y) ."
"; +echo "The difference between x and y is : ". ($x-$y) ."
"; +echo "Multiplication of x and y : ". ($x*$y) ."
"; +echo "Division of x and y : ". ($x/$y) ."
"; +echo "Modulus of x and y : " . ($x%$y) ."
"; ?> diff --git a/operators.php b/operators.php index 4b1face..7a93050 100644 --- a/operators.php +++ b/operators.php @@ -1,46 +1,55 @@
"; -function multOfBoth(int $a, int $b){ - return $a * $b; -} -echo multOfBoth(10,7); +var_dump(1 + 1); echo "

"; - -function divOfBoth(int $a, int $b){ - return $a / $b; -} -echo divOfBoth(70,7); +var_dump(1 - 1); echo "

"; - -function prOfBoth(int $a, int $b){ - return $a % $b; -} -echo prOfBoth(70,7); +var_dump(1 * 2); +echo "

"; +var_dump(10 / 5); +echo "

"; +var_dump(10 % 1); echo "

"; // Create a usage example for comparison operators: ==,! =, <,>, <=,> = -$a = 4; -$b = 3; - -if($a < $b){ - return -1; -}elseif ($a > $b){ - return 1; -}elseif ($a == $b){ - return 0; -}elseif($a != $b){ - return $a; -} +var_dump(1 == TRUE); +var_dump(0 != FALSE); +var_dump(10 > 9); +var_dump(7 < 8); +echo "

"; +$hi = (object) ["hi" => "hi"]; +$biy = (object) ["biy" => "biy"]; +echo $hi <=> $biy; +echo "

"; // Create an example of use for logical operators: &&, And; ||, Or; ! (NOT); Xor +$o = true && false; +var_dump($o); +$y = false && true; +var_dump($y); +$z = true && true; +var_dump($z); +$r = false && false; +var_dump($r); +$q = true || false; +var_dump($q); +$l = false || true; +var_dump($l); +$d = true || true; +var_dump($d); +$s = false || false; +var_dump($s); +echo "

"; + +$var='10am'; +if($var !='12pm'){ +echo 'Get To Work'; +}else{ +echo 'Break Time!'; +} ?> From 2a61d82e66443bd5aed48eb85a550980e4b2f493 Mon Sep 17 00:00:00 2001 From: Iuliia Shikhanova Date: Tue, 20 Dec 2022 13:58:42 +0000 Subject: [PATCH 07/11] ok --- functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions.php b/functions.php index 9ad84a7..d685b99 100644 --- a/functions.php +++ b/functions.php @@ -23,7 +23,7 @@ function all(int $a,int $b, int $c, int $d){ return $a + $b * $c / $d; } echo all(70, 7, 8, 6); -echo "

"; +echo "

";s $x=100; @@ -32,6 +32,6 @@ function all(int $a,int $b, int $c, int $d){ echo "The difference between x and y is : ". ($x-$y) ."
"; echo "Multiplication of x and y : ". ($x*$y) ."
"; echo "Division of x and y : ". ($x/$y) ."
"; -echo "Modulus of x and y : " . ($x%$y) ."
"; +echo "Modulus of x and y : " . ($x%$y) ."
"; ?> From 0b481e82618a9bb1a0f04734790b193b196c9902 Mon Sep 17 00:00:00 2001 From: IuliiaNova <115942758+IuliiaNova@users.noreply.github.com> Date: Tue, 20 Dec 2022 16:44:42 +0000 Subject: [PATCH 08/11] Create README.md --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..4a615e2 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# PHP-basics :technologist: +_The goal of this project is to tough the PHP at the first time and to see the basics concept of thes programming lagueage. There are eleven files that are separated according to the topics._ + +## Resources :pushpin: +- XAMPP +- VisualStudio Code +- PHP v.8.1 +- GIT + +## How to see the code? :globe_with_meridians: +1. Open the XAMPP folder +2. Find "htdocs" +3. Inside of "htdocs" create a new folder where you will store your files +4. In my case it is "PHPBasicsWorkShop" +5. Open XAMPP and "start" Apache +6. Open **localhost** in your navegater and after slash-simbol put the name of your folder from the previous step +7. If everything is ok, you will see the next page=> + +![image](https://user-images.githubusercontent.com/115942758/208716851-6700d7fb-b38b-4707-9ee5-dba95881120d.png) + +## Sources of information :bulb: + +PHP official [website](https://www.php.net/) + +Youtube content: PHP classes, XAMPP, web servers + +### Author :pencil2: +This is a study project made for [Assembler Institute of Technology](https://assemblerinstitute.com/) + by student [**Iuliia Shikhanova**](https://github.com/IuliiaNova) From d938638f0bf8a3de2e4bf9994513b367b08fd048 Mon Sep 17 00:00:00 2001 From: Iuliia Shikhanova Date: Tue, 20 Dec 2022 22:26:21 +0000 Subject: [PATCH 09/11] ok --- functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.php b/functions.php index d685b99..1402a45 100644 --- a/functions.php +++ b/functions.php @@ -23,7 +23,7 @@ function all(int $a,int $b, int $c, int $d){ return $a + $b * $c / $d; } echo all(70, 7, 8, 6); -echo "

";s +echo "

"; $x=100; From 775f8bc3475d99b5cef5aed53ae758566b499e96 Mon Sep 17 00:00:00 2001 From: IuliiaNova <115942758+IuliiaNova@users.noreply.github.com> Date: Wed, 21 Dec 2022 12:32:40 +0000 Subject: [PATCH 10/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a615e2..9066ca3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # PHP-basics :technologist: -_The goal of this project is to tough the PHP at the first time and to see the basics concept of thes programming lagueage. There are eleven files that are separated according to the topics._ +_The goal of this project is to tough the PHP at the first time and to see the basics concept of this programming lagueage. There are eleven files that are separated according to the topics._ ## Resources :pushpin: - XAMPP From 7e3206465b6b65b706cdcbbc144b80487568453b Mon Sep 17 00:00:00 2001 From: IuliiaNova <115942758+IuliiaNova@users.noreply.github.com> Date: Wed, 21 Dec 2022 12:33:14 +0000 Subject: [PATCH 11/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9066ca3..0e63f1c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # PHP-basics :technologist: -_The goal of this project is to tough the PHP at the first time and to see the basics concept of this programming lagueage. There are eleven files that are separated according to the topics._ +_The goal of this project is to tough the PHP at the first time and to see the basics concept of this programming language. There are eleven files that are separated according to the topics._ ## Resources :pushpin: - XAMPP