diff --git a/README.md b/README.md index 7c787c3..91f4ada 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/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 diff --git a/conditionals.php b/conditionals.php new file mode 100644 index 0000000..a982d2a --- /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') { + echo "We are in October"; +} else { + echo "We are in $currentMonth"; +} + +echo '

'; + + + +#CURRENT MINUTE + +$currentMinute = $date->format('i'); + +if ($currentMinute < 10) { + echo "The current minute is less than 10"; +} else if ($currentMinute > 15) { + echo "The current minute is more than 15"; +} else { + echo "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 new file mode 100644 index 0000000..e856d45 --- /dev/null +++ b/dates.php @@ -0,0 +1,31 @@ +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/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 diff --git a/iterators.php b/iterators.php new file mode 100644 index 0000000..37cf19e --- /dev/null +++ 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/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/operators.php b/operators.php new file mode 100644 index 0000000..c61016b --- /dev/null +++ b/operators.php @@ -0,0 +1,85 @@ +
"; + +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 "

"; + +?> + 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 diff --git a/print.php b/print.php new file mode 100644 index 0000000..9817f9c --- /dev/null +++ b/print.php @@ -0,0 +1,17 @@ +", "Second echo instruction
"; + +#PRINT + +print "Print instruction
"; + +#PRINT_R + +$letters = ['a','b','c','d','e']; +print_r ($letters); + + +?> \ No newline at end of file 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 diff --git a/types.php b/types.php new file mode 100644 index 0000000..7758071 --- /dev/null +++ b/types.php @@ -0,0 +1,66 @@ +
"; + +#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"); +var_dump($cars); + +$array = [ + "foo" => "bar", + "bar" => "foo", +]; + +echo "

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

"; + + +#NULL + +$x = "Hello world!"; +$x = null; +var_dump($x); + +echo "

"; + + + +?> \ No newline at end of file