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
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

# https://www.php.net/docs.php

# comentario de una sola linea
/*
comentario de
muchas lineas
*/

$name = "Alejandro toro";
define("TYPE", "admin");

/* Representación de de tipos de variables */

$age = 31;
$name = "Héctor toro";
$isAdmin = true;
$numberFloat = 12.3;
$isNull = null;

// tipos compuestos

$fruits = ["manazana","pera"];
$fruits2 = [
"manzana" => 2,
"pera" => 6,
];
$person = (object) [
"name" => "Alejandro toro",
"age" => 31
];

$lenguaje = "php";
echo "Hola, $lenguaje";





77 changes: 77 additions & 0 deletions Roadmap/01 - OPERADORES Y ESTRUCTURAS DE CONTROL/php/hatorob.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

$a = 20;
$b = "20";
$c = 20;
$isAdmin = false;
// igualdad
if($a == $b) echo "open in If -> true";
// identico
if($a === $c) echo "open in If -> true";
// menor
if($a < 30) echo "is less value";
// menor o igual
if($a <= 20) echo "is less or equal value";
// mayor
if($a > 10) echo "is more value";
// mayor o igual
if($a >= 10) echo "is more or equal value";

//isTrue
if($isAdmin) echo "is true";
// !
if(!$isAdmin) echo "false";

// and
if($a >= 20 && $c<= 20) echo " is and";
// or
if($a >= 20 || $c<= 20) echo " is or";

// if / else

if($a === $b) echo "true";
else echo "false";

// if /elseif / else
if($a >= $c) echo "option 1";
elseif($a === $c) echo "option 2";
else echo "option 3";

$i=1;
// while
while($i <= 10) {
echo "number -> $i";
$i++;
}

// do while -> al menos una vez
$i = 0;
do {
echo $i;
} while ($i > 0);


// match
$fruit = "manzana";

$returnValue = match($fruit) {
"manzana" => "manzana",
"pera" => "pera",
};

echo $returnValue;

// switch

switch ($fruit) {
case 'mazana':
echo "option apple";
break;
case 'pera':
echo "option pera";
break;
default:
echo "any fruit";
break;
}

51 changes: 51 additions & 0 deletions Roadmap/02 - FUNCIONES Y ALCANCE/php/hatorob.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

$name = "Alejandro Toro";

// sin retorno
function welcom() {
echo "Hola mundo!";
}

welcom();

// con parametros y retorno
function sum(int $x, int $y) {
return $x + $y;
}

echo "suma " . sum(2,3);

$product = [
"brand" => "Lg",
"price" => 1000,
];
function getProduct() {
global $product;
$user = "Alejandro Toro";
// no puede obtener la variable de la funcion inicial
function payment($name, $product) {
echo "User $name pago " . print_r($product,1);
}
payment($user, $product);
}
getProduct();

// el php la no se puede tener contexto de las variables locales y globales, dependiendo de
// usar global o pasar por parametro

function getText(string $param1, string $param2) {

$countNumbers = 0;

for($i = 1; $i <= 100; $i++) {
if($i % 3 === 0 && $i % 5 === 0) echo $param1 . " " . $param2;
elseif($i % 3 === 0) echo $param1;
elseif($i % 5 === 0) echo $param2;
else
$countNumbers++;
};
return $countNumbers;
}

echo "cantidad de números " . getText("User", "Toro");