Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,33 @@
<img alt="Version" src="https://img.shields.io/badge/version-1.0-blue.svg?cacheSeconds=2592000" />
</p>

> 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 <!-- omit in toc -->

- [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

<img src="https://docs.github.com/assets/cb-23088/images/help/repository/fork_button.png" alt="Fork on GitHub" width='450'>
- 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

Expand Down
59 changes: 59 additions & 0 deletions arrays.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

/* PUNTO 1 */

$x = ['Javier', 'Pascual', 'Tunez'];
var_dump(implode(" ", $x));
echo "<br><br>";

/* PUNTO 2 */

$b = ['1', '2', '3.55', '4', '5.12'];
var_dump(implode(", ", $b));
echo "<br><br>";

/* 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].".<br>";
echo $colors[1][0].": In stock: ".$colors[1][1].", sold: ".$colors[1][2].".<br>";
echo $colors[2][0].": In stock: ".$colors[2][1].", sold: ".$colors[2][2].".<br>";
echo $colors[3][0].": In stock: ".$colors[3][1].", sold: ".$colors[3][2].".<br>";
echo "<br><br>";

/* PUNTO 4 */

$a[0] = 1;
$a[1] = 3;
$a[2] = 5;
var_dump(count($a));
echo "<br><br>";

/* PUNTO 5 */

$c = array('green', 'red', 'yellow');
$d = array('avocado', 'apple', 'banana');
$e = array_combine($c, $d);

print_r($e);
echo "<br><br>";

/* PUNTO 6 */

$frutas = array('Manzana', 'Sandia', 'Melocoton');
echo end($frutas);
echo "<br><br>";

/* PUNTO 7 */

$animals = array("Horse", "Cat");
array_push($animals, "Dog", "Rat");
print_r($animals);

?>
73 changes: 73 additions & 0 deletions conditionals.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

$a = date("l");

if($a = "Monday") {
echo "We are on Monday";
}

echo "<br><br>";

/* Punto 2 */

$b = date("F");

if($b == "October") {
echo "We are in October";
} else {
echo "We are on $b";
}

echo "<br><br>";

/* 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 "<br><br>";

/* 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";

}



?>
21 changes: 21 additions & 0 deletions dates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

echo date("Y.m.d");

echo "<br><br>";

echo date(DATE_RFC2822);

echo "<br><br>";

echo date("l");

echo "<br><br>";

echo date("m");

echo "<br><br>";

echo date("i");

?>
48 changes: 48 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

$x = 3;
$y = 4;

/* PUNTO 1 */

function sum($x, $y) {
return $x + $y;
}

echo sum($x,$y);

echo "<br><br>";

/* PUNTO 2 */

function mul($x, $y) {
return $x * $y;
}

echo mul($x,$y);

echo "<br><br>";

/* PUNTO 3 */

function div($x, $y) {
return $x / $y;
}

echo div($x,$y);

echo "<br><br>";

/* 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");

?>
36 changes: 36 additions & 0 deletions iterators.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

$i = 1;

for ($i = 1; $i <= 10; $i++) {
echo $i;
}

echo "<br><br>";

$array = array(1, 2, 3, 4);

foreach ($array as &$valor) {
$valor = $valor * 2;
echo "Valor de $valor<br>";
}

echo "<br><br>";

$y = 1;

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

echo "<br><br>";

$x = 0;

do {
echo $x;
} while ($x > 0);


?>
44 changes: 44 additions & 0 deletions maths.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/* Punto 1 */

echo abs(-4.2);
echo "<br>";
echo abs(5);
echo "<br>";
echo abs(-5);

echo "<br><br>";

/* Punto 2 */

echo ceil(4.3);
echo "<br>";
echo ceil(9.999);
echo "<br>";
echo ceil(-3.14);

echo "<br><br>";

/* Punto 3 */

echo max(2, 3, 1, 6, 7);
echo "<br>";
echo max(array(2, 4, 5));

echo "<br><br>";

/* Punto 4 */

echo min(2, 3, 1, 6, 7);
echo "<br>";
echo min(array(2, 4, 5));

echo "<br><br>";

/* Punto 5 */

echo (rand(10,100));


?>
17 changes: 17 additions & 0 deletions operators.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

$a = 4;
$b = 7;

var_dump($a + $b, $a - $b, $a * $b, $a / $b, $a % $b);
echo ($a == $b);
echo "<br><br>";

var_dump($a == $b,$a != $b,$a < $b,$a > $b,$a <= $b,$a >= $b);
echo ($a == $b);
echo "<br><br>";

var_dump($a && $b,$a and $b,$a || $b,$a or $b,! $b,$a xor $b);
echo ($a == $b);

?>
5 changes: 5 additions & 0 deletions phpinfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

phpinfo();

?>
10 changes: 10 additions & 0 deletions print.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

print("Hello World<br>");

echo ("Hello World<br>");

$a = array("a" => "red", "b" => "blue", "c" => "green");
print_r($a);

?>
Loading