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: David T. Pizarro Frick #69

Open
wants to merge 10 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
55 changes: 14 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,24 @@
`#php` `#basics` `#master-in-software-development`
# PHP Basics - MSD OCT22

# PHP Basics <!-- omit in toc -->
Project created by [David Pizarro](https://dtpf.es)

<p>
<img alt="Version" src="https://img.shields.io/badge/version-1.0-blue.svg?cacheSeconds=2592000" />
</p>
## Web

> In this project you will learn 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.
* [https://php-basics.dtpf.es](https://php-basics.dtpf.es/)

## Index <!-- omit in toc -->
## Requriments

- [Requirements](#requirements)
- [Repository](#repository)
- [Technologies used](#technologies-used)
- [Project delivery](#project-delivery)
- [Resources](#resources)
- [PHP] 7 or higher.

## Requirements
## Installing

- Learn the basics to program in PHP
- Understand what a server-side language is and what it is used for
```
clone and execute it on the PHP server
```

## Repository
## Built With

First of all you must fork this project into your GitHub account.
* [PHP](https://www.php.net/)
* [VSCode](https://code.visualstudio.com/)

To create a fork on GitHub is as easy as clicking the “fork” button on the repository page.

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

## 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"

## Resources

- [What can PHP do?](https://www.php.net/manual/es/intro-whatcando.php)
- [Sample guide for README](https://gist.github.com/Villanuevand/6386899f70346d4580c723232524d35a)
- [XAMPP](https://www.apachefriends.org/es/index.html)
- [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)
[PHP]: <https://www.php.net>
131 changes: 131 additions & 0 deletions arrays.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<!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>PHP - Arrays</title>
</head>

<body>
<?php
require './globals.php';

echo '<h2>PHP - Arrays</h2>';

hr();

// Define a simple array composed of text strings
echo '<h4>Define a simple array composed of text strings</h4>';
$fruits = array("Pera", "Manzana", "Guayaba");
echo '
<pre>
$fruits = array("Pera", "Manzana", "Guayaba");
echo $fruits[0].", ".$fruits[1]." and ".$fruits[2]."."
</pre> ==> ';
echo $fruits[0] . ", " . $fruits[1] . " and " . $fruits[2] . ".";

hr();

// Define a simple array consisting of whole numbers and decimal numbers
echo '<h4>Define a simple array consisting of whole numbers and decimal numbers</h4>';
$numbers = array(0.02, 0.4, 1, 3, 5, 100.1);
echo '
<pre>
$numbers = array(0.02, 0.4, 1, 3, 5, 100.1);
foreach ($numbers as $value) {
echo "Value is $value"
}
</pre> ==> <br>';
foreach ($numbers as $value) {
echo "Value is $value <br>";
}

hr();

// Define a multidimensional array
echo '<h4>Define a multidimensional array</h4>';
$games = array(
array("Game 1", 9, 60),
array("Game 2", 7, 50),
array("Game 3", 6, 40),
array("Game 4", 10, 70)
);
echo '
<pre>
$games = array(
array("Game 1", 9, 60),
array("Game 2", 7, 50),
array("Game 3", 6, 40),
array("Game 4", 10, 70)
);
echo $games[0][0] . ": Stars: " . $games[0][1] . "/10, Price: " . $games[0][2] . "€";
echo $games[1][0] . ": Stars: " . $games[1][1] . "/10, Price: " . $games[1][2] . "€";
echo $games[2][0] . ": Stars: " . $games[2][1] . "/10, Price: " . $games[2][2] . "€";
echo $games[3][0] . ": Stars: " . $games[3][1] . "/10, Price: " . $games[3][2] . "€";
</pre> ==> <br>';
echo $games[0][0] . ": Stars: " . $games[0][1] . "/10, Price: " . $games[0][2] . "€.<br>";
echo $games[1][0] . ": Stars: " . $games[1][1] . "/10, Price: " . $games[1][2] . "€.<br>";
echo $games[2][0] . ": Stars: " . $games[2][1] . "/10, Price: " . $games[2][2] . "€.<br>";
echo $games[3][0] . ": Stars: " . $games[3][1] . "/10, Price: " . $games[3][2] . "€.<br>";

hr();

// Execute the function that allows to obtain the length of an array
echo '<h4>Execute the function that allows to obtain the length of an array</h4>';
$days = array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
echo '
<pre>
$days = array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
echo count($days);
</pre> ==> ';
//echo sizeof($days) is other option;
echo count($days);

hr();

// Execute the function that allows to obtain the combination of two arrays
echo '<h4>Execute the function that allows to obtain the combination of two arrays</h4>';
$arrayA = array('cabra', 'luciérnaga', 'gambusino');
$arrayB = array('montesa', 'de luz', 'dorado');
$arrayCombined = array_combine($arrayA, $arrayB);
echo '
<pre>
$arrayA = array("cabra", "luciérnaga", "gambusino");
$arrayB = array("montesa", "de luz", "dorado");
$arrayCombined = array_combine($arrayA, $arrayB);
print_r($arrayCombined);
</pre> ==> ';
print_r($arrayCombined);

hr();

//Execute the function that once is given an array return the last element of it
echo '<h4>Execute the function that once is given an array return the last element of it</h4>';
$array = ['Element 1', 'Element 2', 'Element 3'];
echo '
<pre>
$array = ["Element 1", "Element 2", "Element 3"];
echo end($array);
</pre> ==> ';
echo end($array);

hr();

// Execute the function that once is given an array add a new element to the array in question
echo '<h4>Execute the function that once is given an array add a new element to the array in question</h4>';
$games = ['game 1', 'game 2', 'game 3', 'game 4'];
$addGame = array_push($games, 'game 5');
echo '
<pre>
$games = ["game 1", "game 2", "game 3", "game 4"];
$addGame = array_push($games, "game 5");
print_r($games);
</pre> ==> ';
print_r($games);

?>
</body>

</html>
Binary file added assets/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
132 changes: 132 additions & 0 deletions conditionals.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<!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>PHP - Conditionals</title>
</head>

<body>
<?php
require './globals.php';

echo '<h2>PHP - Conditionals</h2>';

hr();

// Simple condition
echo '<h4>If it`s Monday show message</h4>';
echo '
<pre>
if (date("l", mktime(0, 0, 0, 7, 1, 2000)) == "Monday") {
echo "We are on Monday";
} else {
echo "No message";
}
</pre> ==> ';
if (date("l", mktime(0, 0, 0, 7, 1, 2000)) == 'Monday') {
echo 'We are on Monday';
} else {
echo 'No message';
}

hr();

// Simple condition
echo '<h4>If it`s October show message else show month</h4>';
echo '
<pre>
if (date("F") == "October") {
echo "We are in October";
} else {
echo date("F");
}
</pre> ==> ';
if (date("F") == 'October') {
echo 'We are in October';
} else {
echo date('F');
}

hr();

// Double condition
echo '<h4>Double condition</h4>';
echo '
<pre>
if (date("i") < 10) {
echo "the current minute is less than 10";
} elseif (date("i") > 15) {
echo "the current minute is more than 15";
} else {
echo "does not meet any conditions";
}
</pre> ==> ';
if (date("i") < 10) {
echo 'the current minute is less than 10';
} elseif (date("i") > 15) {
echo 'the current minute is more than 15';
} else {
echo 'does not meet any conditions';
}

hr();

// Switch
echo '<h4>Switch</h4>';
echo '
<pre>
switch (date("l")) {
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;
case "Sunday":
echo "Today is Sunday";
break;
}
</pre> ==> ';
switch (date('l')) {
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;
case 'Sunday':
echo 'Today is Sunday';
break;
}

?>
</body>

</html>
Loading