From 695cdc78e72464613769e0b3b6c607d1409fdd61 Mon Sep 17 00:00:00 2001 From: monica-reverte Date: Mon, 19 Dec 2022 15:12:28 +0100 Subject: [PATCH 01/12] print --- iterators.php | 0 print.php | 11 +++++++++++ 2 files changed, 11 insertions(+) create mode 100644 iterators.php create mode 100644 print.php diff --git a/iterators.php b/iterators.php new file mode 100644 index 0000000..e69de29 diff --git a/print.php b/print.php new file mode 100644 index 0000000..0d13c4b --- /dev/null +++ b/print.php @@ -0,0 +1,11 @@ +", "Second echo instruction
"; + +print "Print instruction
"; + +$letters = ['a','b','c','d','e']; +print_r ($letters); + + +?> \ No newline at end of file From b9979eb1a8b536c6da6fa350aebfd0dffb2169a0 Mon Sep 17 00:00:00 2001 From: monica-reverte Date: Mon, 19 Dec 2022 15:44:27 +0100 Subject: [PATCH 02/12] iterators --- iterators.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ print.php | 6 ++++++ 2 files changed, 54 insertions(+) diff --git a/iterators.php b/iterators.php index e69de29..37cf19e 100644 --- a/iterators.php +++ b/iterators.php @@ -0,0 +1,48 @@ +
"; + +#FOREACH + +$a = [1, 2, 3, 17]; + +foreach ($a as $v) { + echo $v; +} + + +echo "

"; +#WHILE + +$number = 1; + +while($number < 10) { + + echo $number; + $number++; + +} + + +echo "

"; + +#DO WHILE + + +$n = 1; +do { + echo $n; + $n++; + +} while ($n <= 5); + + +?> \ No newline at end of file diff --git a/print.php b/print.php index 0d13c4b..9817f9c 100644 --- a/print.php +++ b/print.php @@ -1,9 +1,15 @@ ", "Second echo instruction
"; +#PRINT + print "Print instruction
"; +#PRINT_R + $letters = ['a','b','c','d','e']; print_r ($letters); From 67111352c62ca52c38bf83cd60e4c9fcdd91d70d Mon Sep 17 00:00:00 2001 From: monica-reverte Date: Mon, 19 Dec 2022 16:34:05 +0100 Subject: [PATCH 03/12] operators --- operators.php | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 operators.php diff --git a/operators.php b/operators.php new file mode 100644 index 0000000..921fe92 --- /dev/null +++ b/operators.php @@ -0,0 +1,84 @@ +
"; + +var_dump($x - $y); +echo "

"; + +var_dump($x * $y); +echo "

"; + +var_dump($x % $y); +echo "

"; + +#COMPARISON OPERATORS + +#Equal + +var_dump($x == $y); +echo "

"; + +#Not equal + +var_dump($x != $y); +echo "

"; + +#Less than + +var_dump($x < $y); +echo "

"; + +#Grater than + +var_dump($x > $y); +echo "

"; + +#Less than or equal to + +var_dump($x <= $y); +echo "

"; + +#Grater than or equal to + +var_dump($x >= $y); +echo "

"; + +#LOGICAL OPERATORS + +#And - True if both $x and $y are true + +var_dump($x && $y); +echo "

"; + +#And - True if both $x and $y are true + +var_dump($x and $y); +echo "

"; + +#Or - True if either $x or $y is true + +var_dump($x || $y); +echo "

"; + +#Or - True if either $x or $y is true + +var_dump($x or $y); +echo "

"; + +#Not - True if $x is not true + +var_dump($x ! $y); +echo "

"; + +#Xor - True if either $x or $y is true, but not both + +var_dump($x xor $y); +echo "

"; + +?> \ No newline at end of file From eeef2a371134c3291ed10b63f8ebc1e052947e68 Mon Sep 17 00:00:00 2001 From: monica-reverte Date: Mon, 19 Dec 2022 20:05:53 +0100 Subject: [PATCH 04/12] dates --- dates.php | 36 ++++++++++++++++++++++++++++++++++++ operators.php | 3 ++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 dates.php diff --git a/dates.php b/dates.php new file mode 100644 index 0000000..2780b9d --- /dev/null +++ b/dates.php @@ -0,0 +1,36 @@ +format ('Y-m-d'); + +echo '

'; + +#CURRENT DAY ANY FORMAT + +echo $date->format ('Y-m-d H:i:s'); +echo '

'; + +#CURRENT DAY + +echo $date->format ('D-d'); +echo '

'; + +#CURRENT MONTH + +echo $date->format ('m'); +echo '

'; + +#CURRENT MINUTE + +echo $date->format ('i'); + + + + + + + +?> \ No newline at end of file diff --git a/operators.php b/operators.php index 921fe92..c61016b 100644 --- a/operators.php +++ b/operators.php @@ -81,4 +81,5 @@ var_dump($x xor $y); echo "

"; -?> \ No newline at end of file +?> + From 029d5cbfcf56383efbfedfa219324e07399883ec Mon Sep 17 00:00:00 2001 From: monica-reverte Date: Tue, 20 Dec 2022 09:24:28 +0100 Subject: [PATCH 05/12] conditionals --- conditionals.php | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ dates.php | 5 ---- types.php | 21 +++++++++++++ 3 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 conditionals.php create mode 100644 types.php diff --git a/conditionals.php b/conditionals.php new file mode 100644 index 0000000..7b7dae6 --- /dev/null +++ b/conditionals.php @@ -0,0 +1,76 @@ +format('D'); + +if ($currentDay == 'Mon') { + echo "We are on Monday"; +} + +echo '

'; + +#CURRENT MONTH + +$currentMonth = $date->format('M'); + +if ($currentMonth == 'Oct') { + print "We are in October"; +} else { + print "We are in $currentMonth"; +} + +echo '

'; + + + +#CURRENT MINUTE + +$currentMinute = $date->format('i'); + +if ($currentMinute < 10) { + print "The current minute is less than 10"; +} else if ($currentMinute > 15) { + print "The current minute is more than 15"; +} else { + print "Does not meet any conditions"; +} +echo '

'; + +#SWITCH + +switch ($currentDay) { + case 'Mon': + echo "Start the week of classes"; + break; + + case 'Tue': + echo "Second day of classes"; + break; + + case 'Wen': + echo "Third day of classes"; + break; + + case 'Thu': + echo "Fourth day of classes"; + break; + + case 'Wen': + echo "Last day of classes"; + break; + + default: + echo "Is weekend"; + break; +} + + + + +?> \ No newline at end of file diff --git a/dates.php b/dates.php index 2780b9d..e856d45 100644 --- a/dates.php +++ b/dates.php @@ -28,9 +28,4 @@ echo $date->format ('i'); - - - - - ?> \ No newline at end of file diff --git a/types.php b/types.php new file mode 100644 index 0000000..3300703 --- /dev/null +++ b/types.php @@ -0,0 +1,21 @@ + \ No newline at end of file From 2af0ca0ad90b0bb97f24807f8356981dce62cfcf Mon Sep 17 00:00:00 2001 From: monica-reverte Date: Tue, 20 Dec 2022 09:37:30 +0100 Subject: [PATCH 06/12] types --- types.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/types.php b/types.php index 3300703..878610d 100644 --- a/types.php +++ b/types.php @@ -10,11 +10,42 @@ $x = 5985; var_dump($x); +#FLOAT - is a number with a decimal point or a number in exponential form +$x = 10.365; +var_dump($x); + + +#STRING + +echo 'this is a simple string'; + +#ARRAY +$cars = array("Volvo","BMW","Toyota"); +var_dump($cars); +$array = [ + "foo" => "bar", + "bar" => "foo", +]; +#OBJECT +$fruits = (object)[ + "fruit 1" => "mango" + "fruit 2" => "apple" + "fruit 3" => "kiwi" +]; + +var_dump($fruits); + + +#NULL + +$x = "Hello world!"; +$x = null; +var_dump($x); From 6740fdb9d3e4bb52679b0c355f43c3a0fde919c1 Mon Sep 17 00:00:00 2001 From: monica-reverte Date: Tue, 20 Dec 2022 10:16:31 +0100 Subject: [PATCH 07/12] math --- conditionals.php | 4 ++-- math.php | 37 +++++++++++++++++++++++++++++++++++++ types.php | 20 +++++++++++++++++--- 3 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 math.php diff --git a/conditionals.php b/conditionals.php index 7b7dae6..e99ea7e 100644 --- a/conditionals.php +++ b/conditionals.php @@ -20,9 +20,9 @@ $currentMonth = $date->format('M'); if ($currentMonth == 'Oct') { - print "We are in October"; + echo "We are in October"; } else { - print "We are in $currentMonth"; + echo "We are in $currentMonth"; } echo '

'; diff --git a/math.php b/math.php new file mode 100644 index 0000000..468811b --- /dev/null +++ b/math.php @@ -0,0 +1,37 @@ +
"; + +#ABSOLUTE + +var_dump(abs($x)); +echo "

"; + +#ROUNDED + +var_dump(round($x)); +echo "

"; + + +#HIGHEST VALUE + +echo(max(0, 150, 30, 20, -8, -200)); +echo "

"; + +#LOWEST VALUE + +echo(min(0, 150, 30, 20, -8, -200)); +echo "

"; + +#RANDOM NUMBER + +echo(rand()); +echo "

"; + + + + +?> \ No newline at end of file diff --git a/types.php b/types.php index 878610d..7758071 100644 --- a/types.php +++ b/types.php @@ -5,21 +5,29 @@ $x = true; $y = false; +echo "

"; + #INTEGRER - non decimal number between -2,147,483,648 and 2,147,483,647 $x = 5985; var_dump($x); +echo "

"; + #FLOAT - is a number with a decimal point or a number in exponential form $x = 10.365; var_dump($x); +echo "

"; + #STRING echo 'this is a simple string'; +echo "

"; + #ARRAY $cars = array("Volvo","BMW","Toyota"); @@ -30,16 +38,20 @@ "bar" => "foo", ]; +echo "

"; + #OBJECT $fruits = (object)[ - "fruit 1" => "mango" - "fruit 2" => "apple" - "fruit 3" => "kiwi" + "fruit 1" => "mango", + "fruit 2" => "apple", + "fruit 3" => "kiwi", ]; var_dump($fruits); +echo "

"; + #NULL @@ -47,6 +59,8 @@ $x = null; var_dump($x); +echo "

"; + ?> \ No newline at end of file From ddf760d99804b211b013fe060d978654714b32b2 Mon Sep 17 00:00:00 2001 From: monica-reverte Date: Tue, 20 Dec 2022 11:02:04 +0100 Subject: [PATCH 08/12] strings --- conditionals.php | 6 ++-- strings.php | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 strings.php diff --git a/conditionals.php b/conditionals.php index e99ea7e..a982d2a 100644 --- a/conditionals.php +++ b/conditionals.php @@ -34,11 +34,11 @@ $currentMinute = $date->format('i'); if ($currentMinute < 10) { - print "The current minute is less than 10"; + echo "The current minute is less than 10"; } else if ($currentMinute > 15) { - print "The current minute is more than 15"; + echo "The current minute is more than 15"; } else { - print "Does not meet any conditions"; + echo "Does not meet any conditions"; } echo '

'; diff --git a/strings.php b/strings.php new file mode 100644 index 0000000..23c7009 --- /dev/null +++ b/strings.php @@ -0,0 +1,78 @@ +
"; + +#TEXT VARIABLE + +echo "I said " . $txt . "

"; + + +#CONCATENATE + +$txt2 = "World"; + +echo "I said " . $txt . " " . $txt2; + +echo "

"; + +#CASE SENSITIVE +$txt3 = "My car is white"; +echo str_replace("white", "red", $txt3); +echo "

"; + +#REPLACE TEXT IN A STRING + +$txt4 = "My car is WHITE"; +echo str_ireplace("white", "red", $txt3); +echo "

"; + +#WRITE TEXT N TIMES + +$txt5 = "It's sunny day
"; + +echo str_repeat($txt5, 3); +echo "

"; + + +#OBTAIN THE LENGTH + +echo strlen($txt); +echo "

"; + + +#OBTAIN POSITION + +echo strpos($txt2, "o"); +echo "

"; + +#CAPITALIZED + +$txtU = strtoupper($txt); +echo $txtU; +echo "

"; + +#LOWERCASE +$txt2L = strtolower($txt2); +echo $txt2L; +echo "

"; + +#OBTAIN TEXT SUBSTRING FROM A GIVEN POSITION + +echo substr($txt, -3); +echo "

"; + + + + + + + + + + +?> \ No newline at end of file From 4e02139feccc26d80e720f6e61c1173c6470a3ed Mon Sep 17 00:00:00 2001 From: monica-reverte Date: Tue, 20 Dec 2022 11:27:17 +0100 Subject: [PATCH 09/12] arrays --- arrays.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 arrays.php diff --git a/arrays.php b/arrays.php new file mode 100644 index 0000000..939d224 --- /dev/null +++ b/arrays.php @@ -0,0 +1,53 @@ +
"; + +#SIMPLE ARRAY NUMBERS + +$numbers = [1,2,3,4,5]; +var_dump($numbers); +echo "

"; + + + +#MULTIDIMENSIONAL ARRAY + +$multiArr = [[1, 2], [2, 3], [4, 5]]; +var_dump ($multiArr); +echo "

"; + +#LENGTH ARRAY + +$length = count($multiArr); +var_dump($length); +echo "

"; + +#COMBINATION ARRAYS + +$combi = array_merge($numbers, $fruits); +var_dump($combi); +echo "

"; + + +#RETURN LAST NUMBER + +$lastN = end($numbers); +var_dump($lastN); +echo "

"; + + + +#ADD NEW ELEMENT + +$newE = array_push($fruits, "orange"); +var_dump($newE); +echo "

"; + + + + +?> \ No newline at end of file From da0bc042425e57edbfc00a215a8ea063d5899f50 Mon Sep 17 00:00:00 2001 From: monica-reverte Date: Tue, 20 Dec 2022 11:48:54 +0100 Subject: [PATCH 10/12] functions --- functions.php | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 functions.php diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..29e59b7 --- /dev/null +++ b/functions.php @@ -0,0 +1,58 @@ +
"; + +#FUNCTION MULTIPLICATION + +function multiply($x, $y) { + return $x * $y; +} +echo multiply(2, 4); +echo "

"; + + +#FUNCTION DIVISION + +function division($x, $y) { + return $x / $y; +} +echo division(4, 2); +echo "

"; + + + +#OPERATION + +function operation($x, $y, $op) +{ + switch ($op) { + case "+": + return sum($x, $y); + break; + case "*": + return multiply($x, $y); + break; + case "/": + return division($x, $y); + break; + default: + return "Error"; + break; + } +} + +echo operation(4, 2, "/"); +echo "

"; + + + + + +?> \ No newline at end of file From 30cda960e569781b0de6ba5dec030f89edaa56c8 Mon Sep 17 00:00:00 2001 From: monica-reverte Date: Tue, 20 Dec 2022 12:36:24 +0100 Subject: [PATCH 11/12] README --- README.md | 31 +++++++++++++------------------ phpinfo.php | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 phpinfo.php diff --git a/README.md b/README.md index 7c787c3..9fa8347 100644 --- a/README.md +++ b/README.md @@ -6,46 +6,41 @@ Version

-> In this project you will learn the basic notions of the famous PHP language which is so used in the world of web development. +> This project shows some guidelines of basics concepts of PHP. > -> What distinguishes PHP from other languages ​​such as Javascript is that the code is executed on the server, generating HTML and sending it to the client. ## Index - [Requirements](#requirements) -- [Repository](#repository) - [Technologies used](#technologies-used) +- [Organization](#organization) - [Project delivery](#project-delivery) - [Resources](#resources) ## Requirements - Learn the basics to program in PHP -- Understand what a server-side language is and what it is used for - -## Repository - -First of all you must fork this project into your GitHub account. - -To create a fork on GitHub is as easy as clicking the “fork” button on the repository page. - -Fork on GitHub +- Understand how to use Xampp +- Improve GitHub ## Technologies used \* PHP -## Project delivery +## Organization + +- Understand pill +- Install Xampp +- Create differents blanks of content +- Write README +- Do de pull request -To deliver this project you must send a Pull Request as explained in the Students Handbook. Remember that the PR title must be with the format -- Solution: + NAME AND SURNAME or TEAM NAMES AND SURNAMES. -- For example: "Solution: Josep Riera", "Solution: Josep Riera, Toni Suárez, Marta Vázquez" ## Resources - [What can PHP do?](https://www.php.net/manual/es/intro-whatcando.php) - [Sample guide for README](https://gist.github.com/Villanuevand/6386899f70346d4580c723232524d35a) +- [PHP Tutorials](https://www.w3schools.com/php/) - [XAMPP](https://www.apachefriends.org/es/index.html) - [How to install XAMPP on Windows](https://www.youtube.com/watch?v=h6DEDm7C37A) -- [What is a web server?](https://www.youtube.com/watch?v=Yt1nesKi5Ec) -- [Web server basics](https://www.youtube.com/watch?v=3VqfpVKvlxQ) + diff --git a/phpinfo.php b/phpinfo.php new file mode 100644 index 0000000..9782ad8 --- /dev/null +++ b/phpinfo.php @@ -0,0 +1,14 @@ + \ No newline at end of file From 2dd2574aa28753855e9d7d488d135ec872f004d3 Mon Sep 17 00:00:00 2001 From: monica-reverte Date: Tue, 20 Dec 2022 12:42:21 +0100 Subject: [PATCH 12/12] cambio --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9fa8347..91f4ada 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ - Install Xampp - Create differents blanks of content - Write README -- Do de pull request +- Do de pull request. ## Resources