Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Solution: Javier Fernández" #56

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
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
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"abusaidm.html-snippets"
]
}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,8 @@ To deliver this project you must follow the steps indicated in the document:
- [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)



Note:
All the comments are spanish/english just to save this code and use it in the future.
51 changes: 51 additions & 0 deletions Transaction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/*
Single class per file is the recomended


$amount y $description daran NULL si no le asignamos un valor.Es el modo default

declare(strict_types=1);

class Transaction
{

public float $amount;
public string $description;


public function __construct(float $amount, $description)
{
$this-> amount = $amount;
$this-> description = $description;
}

public function addTax(float $rate)
{
$this->amount += $this->amount * $rate / 100;
}




public function applyDiscount(float $rate)
{
$this->amount += $this->amount * $rate / 100;
}

}



Construction method or magic method y se escribe asi: __


Definicion rapida : class comoSeLlame {var $propiedad y function method()};
*/






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


/* $array = array('Paco', 'Pepe', 'Raul');
print_r($array);

$array = array(1, 1, 1, 1, 1, 8 => 1, 4 => 1, 19, 3 => 13);
print_r($array); */


/* Multidimensional array
$data = array(
array(1, 2, 3),
"John",
"Jane"
);

print_r($data);

echo $data[0][1]; */





/* Lo que metemos dentro del corchete se llama index o key, pero si no se definen las keys, PhP lo hara automaticamente,empezando en 0, */

/* $progranmingLanguages = ['PHP', 'Java', 'Python'];

$name = 'Gio';
*/
/* echo $name[1];

echo $progranmingLanguages[0]; */


/* Para ver si el item existe y envitar errores podemos usar por ejemplo:
la funcion isset . ideal para saber si existe*/

/* var_dump(isset($programingLanguages[0]));
var_dump(isset($programingLanguages[3])); */


/* Y si queremos cambiar pro ejemplo 'Java' por C++? */


/* $progranmingLanguages[1] = 'C++'; */
/* echo $progranmingLanguages[1]; */
/* var_dump($progranmingLanguages);
print_r($progranmingLanguages); */

/* la mejor manera de verlo seria asi:
echo '<pre';
print_r($programingLanguages);
echo '</pre>';
*/



/*$progranmingLanguages = ['PHP', 'Java', 'Python'];

$progranmingLanguages[] = 'C++'; /* Esta es la forma mas sencilla */
/*array_push($progranmingLanguages, 'C++', 'C', 'GO'); /* Esta es mas complicada */
/* estas son las dos formas de agreganrelementos al array como el push() de javascript
*/



/* array_pad() - Rellena un array a la longitud especificada con un valor
list() - Asignar variables como si fueran un array
count() - Cuenta todos los elementos de un array o algo de un objeto
range() - Crear un array que contiene un rango de elementos
foreach
El tipo array

https://www.php.net/manual/es/function.array.php
https://www.youtube.com/watch?v=wLoPGWwMamc */
?>





<?php


$programingLanguages = ['PHP', 'Java', 'Python'];


var_dump($progranmingLanguages['php']);



$progranmingLanguages = [
'php ' => '8.0',
'python' > '3.9'
];



/* echo '<pre';
print_r($programingLanguages);
echo '</pre>';

echo $progranmingLanguages['php'];


$programingLanguages['go'] = '1.15';

echo $programingLanguages;



https://www.youtube.com/watch?v=C8ZFLq24g_A
https://www.php.net/manual/es/function.array.php */

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


/* CONDITIONAL STATEMENTS */
/* $Monday = 1;
$Tuesday = 2;
$Wednesday = 3;
$Thursday = 4;
$Friday = 5;
$Saturday = 6;
$Sunday = 7; */

/* $date = date("d");
$dayinweek = date("w"); */

/* $Monday = 5;
$Tuesday = 2;

if ($Monday > $Tuesday) {
echo "We are on Monday";
}


$date1 = "10";
$date2 = "05";

if ($date1 > $date2)
echo "We are in October $date1";
else
echo " We are in May $date2";
*/




/* elseif/else if */
/* $a = 10;
$b = 15;


if ($a < $b) {
echo "The current minute is less than 10";
} elseif ($a > $b) {
echo "The current minute is more than 15";
} else {
echo "Does not meet any conditions";
}


Switch: */


$x = 8;


switch ($x) {
case 1:
echo "The answer is 1";
break;
case 2:
echo "This answer is 2";
break;
case 3:
echo "The answer is 3";
break;
case 4:
echo "The answer is 4";
break;
case 5:
echo "The answer is 5";
break;
default:
echo "There is no answer";
}




?>
71 changes: 71 additions & 0 deletions dates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>

<body>


<!-- importante :
'tomorrow'
'next tuesday'
'last day of month'
'tomorrow noon'
'10/10/2021 7:00'
-->


<?php
/* Date & Time */

$currentTime = time();

echo $currentTime . '<br />' ;

/* echo $currentTime + 5 * 24 * 60 *60; los dias dentro de 5 dias, 5 dias, 24horas..etc */

/* echo $currentTime - 60 * 60 * 24; el tiempo de ayer */

/* Importante */
echo date('m/d/Y g:ia ') . '<br />';

/* la g nos da el formato 24h sin ceros, la i los minutos sin ceros y la a nos dice si es A.M o P.M */


/* Otro ejemplo */
echo date('m/d/Y g:ia ', $currentTime + 5 * 24 * 60 *60 ) . '<br />';

/* Y para cambiar la franja horaria, seria algo asi: */
date_default_timezone_set('UTC');

echo date('m/d/Y g:ia ') . '<br />';


echo date_default_timezone_get() . '<br />';


/* Otra cosa importante para convertir 'parse dates' string representation en unidades de tiempo, ejemplo: */

echo date('m/d/Y g:ia', mktime(0, 0, 0, 4, 10, null)) . '<br />';
/* String to time function */
echo strtotime('2021-01-18 07:00:00') . '<br />';

/* Mola poder ponerle por ejemplo el tomorrow asi: */
/* o 'las day of february' o 'second friday of January' etc */
echo date('m/d/Y g:ia', strtotime('tomorrow'));


?>

<!-- Info importante por si se me olvida algo :
https://www.php.net/manual/en/datetime.format.php
https://www.php.net/manual/en/timezones.php
https://www.php.net/manual/en/datetime.formats.relative.php -->
</body>

</html>
Loading