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
45 changes: 45 additions & 0 deletions arrays.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!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>File arrays.php</title>
</head>

<body>
<a href="http://127.0.0.1/php-basics" style="text-decoration: none;background-color:black;color:white;">⮜Go Back</a>
<h1>library of functionalities php</h1>
<h2>php arrays</h2>

<?php

$simpleArrString = array("hello", "there", "all", "good",);

$simpleArrNumDec = array(12, 3.14, 65, 34, 2.4);

$multidimensArr = array(
array("Hello", 1),
array("Hello", 2),
array("Hello", 3),
);

var_dump(count($simpleArrString));
echo "<br>";

$simpleArrs = $simpleArrString + $simpleArrNumDec;
var_dump($simpleArrs);
echo "<br>";

echo end($simpleArrString);
echo "<br>";

array_push($simpleArrNumDec, 123, 456, 789);
print_r($simpleArrNumDec);

?>

</body>

</html>
78 changes: 78 additions & 0 deletions conditionals.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!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>File conditionals.php</title>
</head>

<body>
<a href="http://127.0.0.1/php-basics" style="text-decoration: none;background-color:black;color:white;">⮜Go Back</a>
<h1>library of functionalities php</h1>
<h2>php conditionals</h2>

<?php

$day = date("l");

if ($day == "Monday") {
echo "We are on Monday";
}
print "<br>";


$month = date("F");

if ($month == "October") {
echo "We are in October";
} else {
echo "We aren't in October. We are in " . $month;
}
print "<br>";


$minute = date("i");

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


$switchDay = date("l");

switch ($switchDay) {
case "Monday":
echo "Happy Monday";
break;
case "Tuesday":
echo "Happy Tuesday";
break;
case "Wednesday":
echo "Happy Wednesday";
break;
case "Thursday":
echo "Happy Thursday";
break;
case "Friday":
echo "Happy Friday";
break;
case "Saturday":
echo "Happy Saturday";
break;
case "Sunday":
echo "Happy Sunday";
break;
}

?>

</body>

</html>
39 changes: 39 additions & 0 deletions dates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!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>File dates.php</title>
</head>

<body>
<a href="http://127.0.0.1/php-basics" style="text-decoration: none;background-color:black;color:white;">⮜Go Back</a>
<h1>library of functionalities php</h1>
<h2>php DateTime class</h2>

<?php
$objDateTime = new DateTime('NOW');


echo $objDateTime->format('Y-m-d');
echo "<br>";

echo $objDateTime->format(DateTimeInterface::COOKIE);
echo "<br>";

echo "Today is " . date("l");
echo "<br>";

echo "Current month in numerical format " . date("m");
echo "<br>";

echo "Current minute with leading zeros " . date("i");
echo "<br>";

?>

</body>

</html>
36 changes: 36 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!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>File functions.php</title>
</head>

<body>
<a href="http://127.0.0.1/php-basics" style="text-decoration: none;background-color:black;color:white;">⮜Go Back</a>
<h1>library of functionalities php</h1>
<h2>php functions</h2>

<?php

$first = 15;
$second = 10;
$sum = $first + $second;
echo "Result: " . $sum . "<br>";

$mul = $first * $second;
echo "Result: " . $mul . "<br>";

$dis = $first / $second;
echo "Result: " . $dis . "<br>";

$opr = $first - $second;
echo "Result: " . $opr . "<br>";

?>

</body>

</html>
152 changes: 152 additions & 0 deletions iterators.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<!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>File iterators.php</title>
</head>

<body>
<a href="http://127.0.0.1/php-basics" style="text-decoration: none;background-color:black;color:white;">⮜Go Back</a>
<h1>library of functionalities php</h1>
<h2>php iterators using "for"</h2>

<?php

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

echo "<br>";

for ($i = 1;; $i++) {
if ($i > 10) {
break;
}
echo $i;
echo " ";
}

echo "<br>";

$i = 1;
for (;;) {
if ($i > 10) {
break;
}
echo $i;
echo " ";
$i++;
}

echo "<br>";

for ($i = 1, $j = 0; $i <= 10; $j += $i, print $i, print " ", $i++);


?>



<br><br>
<h2>php iterators using "forEach"</h2>

<?php

$a = array(1, 2, 3, 17);

foreach ($a as $v) {
echo "Valor actual de \$a: $v.\n";
}
echo "<br>";


$a = array(1, 2, 3, 17);

$i = 0;

foreach ($a as $v) {
echo "\$a[$i] => $v.\n";
$i++;
}
echo "<br>";


$a = array(
"uno" => 1,
"dos" => 2,
"tres" => 3,
"diecisiete" => 17
);

foreach ($a as $k => $v) {
echo "\$a[$k] => $v.\n";
}
echo "<br>";


$a = array();
$a[0][0] = "a";
$a[0][1] = "b";
$a[1][0] = "y";
$a[1][1] = "z";

foreach ($a as $v1) {
foreach ($v1 as $v2) {
echo "$v2\n";
}
}
echo "<br>";


foreach (array(1, 2, 3, 4, 5) as $v) {
echo "$v\n";
}

?>



<br><br>
<h2>php iterators using "while"</h2>

<?php

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


$i = 1;
while ($i <= 10) :
echo "$i\n";
$i++;
endwhile;

?>



<br><br>
<h2>php iterators using "do while"</h2>

<?php

$i = 1;

do {
echo "The number is: $i <br>";
$i++;
} while ($i <= 5);

?>

</body>

</html>
Loading