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

Valentino Traverso Project #62

Open
wants to merge 3 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
54 changes: 4 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,5 @@
`#php` `#basics` `#master-in-software-development`
# PHP Basics
_This is a project to learn few things we could do with PHP._

# PHP Basics <!-- omit in toc -->

<p>
<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.
>
> 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 -->

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

First of all you must fork this project into your GitHub account.

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)
## Author
* **[Valentino Traverso](https://github.com/valentraverso)** - Developer
22 changes: 22 additions & 0 deletions arrays.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

// Array Strings
$arrayStr = array("Hello", "World", "!");

// Array Numbers
$arrayNum = array(1, 2, 3.5);

// Multidimensional array
$arrayMulti = array(["hello"], ["world"]);

// Array length
sizeof($arrayMulti);

// Array Combination
array_combine($arrayStr, $arrayNum);

// Last position of an array
end($arrayNum);

// Push elements to an array
array_push($arrayStr, "Argentina")
56 changes: 56 additions & 0 deletions conditionals.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

// Get date
$actualDate = new DateTime();

// Show msg if its monday
if($actualDate->format('D') === 'Mon'){
print "We are on Monday";
}

echo '<br><br>';

// Show msg if its october
if($actualDate->format('M') === 'Oct'){
print "We are in October";
}else{
print 'The actual month is '.$actualDate->format('M');
}

echo '<br><br>';

// Show msg if before 10 minutes and if after 15 minutes
if($actualDate->format('i') < 10){
print "the current minute is less than 10";
}else if($actualDate->format('i') > 15){
print "the current minute is more than 15";
}else{
print "does not meet any conditions";
}

echo '<br><br>';

// Show the actual day with a msg
switch($actualDate->format('D')){
case 'Mon':
print 'Today is Monday';
break;
case 'Tue':
print 'Today is Tuesday';
break;
case 'Wen':
print 'Today is Wednesday';
break;
case 'Thu':
print 'Today is Thursday';
break;
case 'Fri':
print 'Today is Friday';
break;
case 'Sat':
print 'Today is Saturday';
break;
case 'Sun':
print 'Today is Sunday';
break;
}
27 changes: 27 additions & 0 deletions dates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

//get ddate
$date = new DateTime();

// Display actual date
print_r($date);

echo '<br><br>';

// Display year month day
print $date->format('Y-m-d');

echo '<br><br>';

// Display day
print $date->format('d');

echo '<br><br>';

// Display month
print $date->format('m');

echo '<br><br>';

// Display minutes 0-59
print $date->format('i');
35 changes: 35 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

// Function return sum of 2 numbers
function sum($a, $b){
return $sum = $a + $b;
}

// Function return multiplication of 2 numbers
function multiply($a, $b){
return $multiply = $a * $b;
}

// Function divide 2 numbers
function divide($a, $b){
return $divide = $a / $b;
}

// fucntion return rand operation
function calculator($a, $b, $operator){
switch($operator){
case '+':
$result = $a + $b;
break;
case '-':
$result = $a - $b;
break;
case '/':
$result = $a / $b;
break;
default:
$result = "Operator don't allowed";
break;
}
return $result;
}
35 changes: 35 additions & 0 deletions iterators.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

print 'Loop For<br>';

for($i = 0; $i < 10; $i++){
print $i.' ';
}

print '<br>Loop forEach<br>';

$forEach = array(1, 2, 3, 4);
forEach($forEach as $num){
print_r($num.' ');
}

print '<br>Loop While<br>';

$while = 1;
while($while <= 4){
print $while.' ';

$while++;
}

print '<br>Loop Do While<br>';

$doWhile = 1;

do{
print_r($doWhile);

$doWhile++;
}while($doWhile <= 0);

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

// Return an absolute number
function absolute(){
$absolute = var_dump(abs(5-10));
return $absolute;
}

absolute();

// Return a rounded of a decimal number
function roundExcercise(){
$round = round(5.8);
return $round;
}

roundExcercise();

// Return the greater of an array
function mayor($num){
return $max = max($num);
}

$arrNum = array(1, 5, 3, 10);
mayor($arrNum);

// return de least number
function minor($num){
return $min = min($num);
}

minor($arrNum);

// Return a random number between 1 and 100
function randomNum(){
print rand(1, 100);
}

randomNum();
12 changes: 12 additions & 0 deletions operators.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

// All the operators
var_dump(1 + 2 / 2 * 5 - 1 % 5);

// Less equal
var_dump(555 <= 1000);

// equal or less
var_dump(10 == 10 && 50 < 60);

?>
2 changes: 2 additions & 0 deletions phpinfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
phpinfo();
15 changes: 15 additions & 0 deletions print.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

// Types of printing in display

echo 'Hello World!';

echo '<br><br>';

print 'Hello World!';

print '<br><br>';

print_r(var_dump(5));

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

print "Hello World";

$world = "world";

print "Hello $world";

print 'Hello'.$world;

// Replace a word of a string
print str_replace("nothing", $world, "Hello nothing");

// Replace a word of a string (no sensitive)
print str_ireplace("NothinG", $world, "Hello nothing");

// Repeat N times a string
print str_repeat("Hello World", 2);

// Show the length of a string
print strlen("Hello world");

// Show the initial position of a string
print strpos("Hello World", "World");

// Capitalize
print ucfirst("hello world");

// Convert all the text to upper case
print strtoupper("hello world");

// convert all the text to lower case
print strtolower("HELLO WORLD");

// Print a substring of a string
print substr("Hello World", 7);
19 changes: 19 additions & 0 deletions types.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

$boolean = true;

$int = 2;

$float = 10.2;

$string = 'Hello World';

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

class object{
private $name;
private $lastName;
private $phone;
}

$null = null;