diff --git a/README.md b/README.md index 7c787c3..d4c8b8c 100644 --- a/README.md +++ b/README.md @@ -6,40 +6,33 @@ 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. +> In this project we learnt the basic notions of the famous PHP language which is so used in the world of web development. > > 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 +- [Organization](#organitzation) - [Requirements](#requirements) -- [Repository](#repository) - [Technologies used](#technologies-used) -- [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 +## Organization -First of all you must fork this project into your GitHub account. +- In this project in the first instance I have created all the necessary files for its further development. Once finished, I modified the readme and made a "pull request" to upload the project with all the changes to Github. -To create a fork on GitHub is as easy as clicking the “fork” button on the repository page. +## Requirements -Fork on GitHub +- Learn the basics to program in PHP. +- Understand what a server-side language is and what it is used for. +- Learn to use a LocalServer with XAMPP. ## Technologies used \* PHP - -## Project delivery - -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" +\* XAMPP +\* VSCode ## Resources diff --git a/arrays.php b/arrays.php new file mode 100644 index 0000000..2341d98 --- /dev/null +++ b/arrays.php @@ -0,0 +1,59 @@ +
"; + +/* PUNTO 2 */ + +$b = ['1', '2', '3.55', '4', '5.12']; +var_dump(implode(", ", $b)); +echo "

"; + +/* PUNTO 3 */ + +$colors = array ( + array("Red",22,18), + array("Blue",15,13), + array("Green",5,2), + array("Black",17,15) + ); + +echo $colors[0][0].": In stock: ".$colors[0][1].", sold: ".$colors[0][2].".
"; +echo $colors[1][0].": In stock: ".$colors[1][1].", sold: ".$colors[1][2].".
"; +echo $colors[2][0].": In stock: ".$colors[2][1].", sold: ".$colors[2][2].".
"; +echo $colors[3][0].": In stock: ".$colors[3][1].", sold: ".$colors[3][2].".
"; +echo "

"; + +/* PUNTO 4 */ + +$a[0] = 1; +$a[1] = 3; +$a[2] = 5; +var_dump(count($a)); +echo "

"; + +/* PUNTO 5 */ + +$c = array('green', 'red', 'yellow'); +$d = array('avocado', 'apple', 'banana'); +$e = array_combine($c, $d); + +print_r($e); +echo "

"; + +/* PUNTO 6 */ + +$frutas = array('Manzana', 'Sandia', 'Melocoton'); +echo end($frutas); +echo "

"; + +/* PUNTO 7 */ + +$animals = array("Horse", "Cat"); +array_push($animals, "Dog", "Rat"); +print_r($animals); + +?> \ No newline at end of file diff --git a/conditionals.php b/conditionals.php new file mode 100644 index 0000000..ad15678 --- /dev/null +++ b/conditionals.php @@ -0,0 +1,73 @@ +
"; + +/* Punto 2 */ + +$b = date("F"); + +if($b == "October") { + echo "We are in October"; +} else { + echo "We are on $b"; +} + +echo "

"; + +/* PUNTO 3 */ + +$c = date("i"); + +if($c <= "10") { + echo "The current minute is less than 10"; +} elseif($c >= "16") { + echo "The current minute is more than 15"; +} else { + echo "does not meet any conditions"; +} + +echo "

"; + +/* PUNTO 4 */ + +$day = date("l"); + +switch($day) { + + case "Monday"; + echo "Today is Monday"; + break; + + case "Tuesday"; + echo "Today is Tuesday"; + break; + + case "Wednesday"; + echo "Today is Wednesday"; + break; + + case "Thursday"; + echo "Today is Thursday"; + break; + + case "Friday"; + echo "Today is Friday"; + break; + + case "Saturday"; + echo "Today is Saturday"; + break; + + default: echo "Today is the las day of the week"; + +} + + + +?> \ No newline at end of file diff --git a/dates.php b/dates.php new file mode 100644 index 0000000..3e6a715 --- /dev/null +++ b/dates.php @@ -0,0 +1,21 @@ +
"; + +echo date(DATE_RFC2822); + +echo "

"; + +echo date("l"); + +echo "

"; + +echo date("m"); + +echo "

"; + +echo date("i"); + +?> \ No newline at end of file diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..47f0e8c --- /dev/null +++ b/functions.php @@ -0,0 +1,48 @@ +
"; + +/* PUNTO 2 */ + +function mul($x, $y) { + return $x * $y; +} + +echo mul($x,$y); + +echo "

"; + +/* PUNTO 3 */ + +function div($x, $y) { + return $x / $y; +} + +echo div($x,$y); + +echo "

"; + +/* PUNTO 4 */ + +function operation($x, $y, $operation) { + if($operation == "add") { + return $x + $y; + } else if ($operation == "multiply") { + return$x * $y; + } +} + +echo operation(7, 6, "multiply"); + +?> \ No newline at end of file diff --git a/iterators.php b/iterators.php new file mode 100644 index 0000000..173c8e4 --- /dev/null +++ b/iterators.php @@ -0,0 +1,36 @@ +
"; + +$array = array(1, 2, 3, 4); + +foreach ($array as &$valor) { + $valor = $valor * 2; + echo "Valor de $valor
"; +} + +echo "

"; + +$y = 1; + +while ($y <= 10) { + echo $y; + $y++; +} + +echo "

"; + +$x = 0; + +do { + echo $x; +} while ($x > 0); + + +?> \ No newline at end of file diff --git a/maths.php b/maths.php new file mode 100644 index 0000000..1c9585f --- /dev/null +++ b/maths.php @@ -0,0 +1,44 @@ +"; +echo abs(5); +echo "
"; +echo abs(-5); + +echo "

"; + +/* Punto 2 */ + +echo ceil(4.3); +echo "
"; +echo ceil(9.999); +echo "
"; +echo ceil(-3.14); + +echo "

"; + +/* Punto 3 */ + +echo max(2, 3, 1, 6, 7); +echo "
"; +echo max(array(2, 4, 5)); + +echo "

"; + +/* Punto 4 */ + +echo min(2, 3, 1, 6, 7); +echo "
"; +echo min(array(2, 4, 5)); + +echo "

"; + +/* Punto 5 */ + +echo (rand(10,100)); + + +?> \ No newline at end of file diff --git a/operators.php b/operators.php new file mode 100644 index 0000000..d6af941 --- /dev/null +++ b/operators.php @@ -0,0 +1,17 @@ +
"; + +var_dump($a == $b,$a != $b,$a < $b,$a > $b,$a <= $b,$a >= $b); +echo ($a == $b); +echo "

"; + +var_dump($a && $b,$a and $b,$a || $b,$a or $b,! $b,$a xor $b); +echo ($a == $b); + +?> \ No newline at end of file diff --git a/phpinfo.php b/phpinfo.php new file mode 100644 index 0000000..6480abf --- /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..f1192c0 --- /dev/null +++ b/print.php @@ -0,0 +1,10 @@ +"); + +echo ("Hello World
"); + +$a = array("a" => "red", "b" => "blue", "c" => "green"); +print_r($a); + +?> \ No newline at end of file diff --git a/strings.php b/strings.php new file mode 100644 index 0000000..fc7deb0 --- /dev/null +++ b/strings.php @@ -0,0 +1,73 @@ +
"; + +/* PUNTO 2 */ + +$a = "Hello World"; +print "$a"; +echo "

"; + +/* PUNTO 3 */ + +print "Id like to say $a"; +echo "

"; + +/* PUNTO 4 */ + +echo str_replace("World","Javier", $a); +echo "

"; + +/* PUNTO 5 */ + +$b = "HELLO WORLD"; + +echo str_ireplace("world","Javier", $b); +echo "

"; + +/* PUNTO 6 */ + +echo str_repeat($a, 5); +echo "

"; + +/* PUNTO 7 */ + +echo strlen($a); +echo "

"; + +/* PUNTO 8 */ + +$x = 'abcdef abcdef'; +$pos = strpos($x, 'a', 1); +echo $pos; +echo "

"; + +/* PUNTO 9 */ + +$c = "hello world"; +$c = ucfirst($c); +echo $c; +echo "

"; + +/* PUNTO 10 */ + +$d = "HELLO WORLD"; +$d = ucfirst($d); +$d = ucfirst(strtolower($d)); +echo $d; +echo "

"; + +/* PUNTO 11 */ + +$e = substr("Javier", -1); +echo "$e

"; +$f = substr("Javier", -2); +echo "$f

"; +$g = substr("Javier", -3, 1); +echo "$g"; + + +?> \ No newline at end of file diff --git a/types.php b/types.php new file mode 100644 index 0000000..f4a456d --- /dev/null +++ b/types.php @@ -0,0 +1,58 @@ +
"; + +/* integer */ + +$c = 5985; +var_dump($c); + +echo "

"; + +/* float */ + +$d = 10.365; +var_dump($d); + +echo "

"; + +/* String */ + +$f = "Hello world!"; +$g = 'Hello world!'; + +echo $f; +echo "
"; +echo $g; + +echo "

"; + +/* Array */ + +$cars = array("Volvo","BMW","Toyota"); +var_dump($cars); + +echo "

"; + +/* object */ + +$object = (object) [ + 'propertyOne' => 'foo', + 'propertyTwo' => 42, +]; + +var_dump($object); +echo "

"; + +/* null */ + +$h = "Hello world!"; +$i = null; +var_dump($i); + +?> \ No newline at end of file