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: Iuliia Shikhanova #79

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
66 changes: 22 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,29 @@
`#php` `#basics` `#master-in-software-development`
# PHP-basics :technologist:
_The goal of this project is to tough the PHP at the first time and to see the basics concept of this programming language. There are eleven files that are separated according to the topics._

# PHP Basics <!-- omit in toc -->
## Resources :pushpin:
- XAMPP
- VisualStudio Code
- PHP v.8.1
- GIT

<p>
<img alt="Version" src="https://img.shields.io/badge/version-1.0-blue.svg?cacheSeconds=2592000" />
</p>
## How to see the code? :globe_with_meridians:
1. Open the XAMPP folder
2. Find "htdocs"
3. Inside of "htdocs" create a new folder where you will store your files
4. In my case it is "PHPBasicsWorkShop"
5. Open XAMPP and "start" Apache
6. Open **localhost** in your navegater and after slash-simbol put the name of your folder from the previous step
7. If everything is ok, you will see the next page=>

> 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.
![image](https://user-images.githubusercontent.com/115942758/208716851-6700d7fb-b38b-4707-9ee5-dba95881120d.png)

## Index <!-- omit in toc -->
## Sources of information :bulb:

- [Requirements](#requirements)
- [Repository](#repository)
- [Technologies used](#technologies-used)
- [Project delivery](#project-delivery)
- [Resources](#resources)
PHP official [website](https://www.php.net/)

## Requirements
Youtube content: PHP classes, XAMPP, web servers

- 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 :pencil2:
This is a study project made for [Assembler Institute of Technology](https://assemblerinstitute.com/)
by student [**Iuliia Shikhanova**](https://github.com/IuliiaNova)
31 changes: 31 additions & 0 deletions arrays.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
$nombres = array("Ana", "Maria", "Lucia");
$numbers = array(1, 3.2, 5);

#multidimensional array
$cars = array (
array("Volvo",22,18),
array("BMW",15,13),
array("Saab",5,2),
array("Land Rover",17,15)
);
echo "<br><br>";
#obtain the length of an array
var_dump(count($cars));

#combination of two arrays

$result = array_combine($nombres, $numbers);

print_r($result);
echo "<br><br>";

#Execute the function that once is given an array return the last element of it
echo end($nombres);
echo "<br><br>";

#Execute the function that once is given an array add a new element to the array in question

array_push($nombres, "Olga", "Katy");
print_r($nombres);
?>
47 changes: 47 additions & 0 deletions conditionals.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

$day = "Monday";
$month = "December";

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

if($month == "October"){
echo "We are in October <br><br>";
}else echo "We are in " . date("F") . "<br><br>";

// Doble condition

$minute = 9;
if($minute < 10){
echo "the current minute is less than 10 <br><br>";
}elseif($minute>15){
echo "the current minute is more than 15";
}else echo "does not meet any conditions";

// Switch
$today = "friday";

switch($today){
case 'Monday':
echo "Let start the week <br><br>";
break;

case 'Wednesday':
echo "The are just three days more to finish the week! <br><br>";
break;

case 'friday':
echo "The last working day <br><br>";
break;

case 'Sunday':
echo "Tomorrow we will start again <br><br>";
break;

default: echo "nothing to do";
}


?>
26 changes: 26 additions & 0 deletions dates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
//Instance DateTime class and then invoke the format method with the argument “Y-m-d” to show year-month-day
$datetime = new DateTime();
echo $datetime->setDate(2022, 12, 20)
->setTime(12, 00)
->setTimezone(new DateTimeZone('America/New_York'))
->format("Y-m-d\\TH:i:sP");
echo "<br> <br>";

// date
echo "Today is " . date("Y-m-d") . "<br>";

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

//month in numerical format (1-12)
echo "Today is " . date("m") . "<br>";

//current minute with leading zeros (00 - 59)
echo "Now is " . date("i") . "<br>";

?>




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

function sumOfBoth(int $a, int $b){
return $a + $b;
}
echo sumOfBoth(5,7);
echo "<br><br>";

function multOfBoth(int $a, int $b){
return $a * $b;
}
echo multOfBoth(10,7);
echo "<br><br>";

function divOfBoth(int $a, int $b){
return $a / $b;
}
echo divOfBoth(70,7);
echo "<br><br>";


function all(int $a,int $b, int $c, int $d){
return $a + $b * $c / $d;
}
echo all(70, 7, 8, 6);
echo "<br><br>";


$x=100;
$y=60;
echo "The sum of x and y is : ". ($x+$y) ."<br />";
echo "The difference between x and y is : ". ($x-$y) ."<br />";
echo "Multiplication of x and y : ". ($x*$y) ."<br />";
echo "Division of x and y : ". ($x/$y) ."<br />";
echo "Modulus of x and y : " . ($x%$y) ."<br />";
?>

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

// ForEach

$array = array(1, 2, 3, 4);
foreach ($array as &$valor) {
$valor = $valor * 2;
}

print_r ($array);
echo "<br><br>";

// For

$i = 0;
for ($i=0; $i < 10; $i++){
echo $i;
}
echo "<br><br>";

// While
$y = 0;
while ($y < 10){
$y++;
echo "While: $y";
}
echo "<br><br>";

// Do-while que imprime 012345678910
$x = 0;
do{
$x++;
echo "Do-While: $x";
} while ($x<10);

?>
39 changes: 39 additions & 0 deletions maths.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
//Define a variable whose value is the result of the function that returns an absolute value

var_dump(abs(-4.2));
echo"<br><br>";
var_dump(abs(5));
echo"<br><br>";
var_dump(abs(-5));
echo"<br><br>";

//Define a variable whose value is the result of the function that returns a rounded value to the next highest integer.

echo ceil(4.3); // 5
echo"<br><br>";
echo ceil(9.999); // 10
echo"<br><br>";
echo ceil(-3.14);
echo"<br><br>";

//Define a variable whose value is the result of the function that returns the highest value of a series of values ​​that are received by parameter.
echo max(2, 3, 1, 6, 7);
echo"<br><br>";
echo max(array(2, 4, 5));
echo"<br><br>";

//Define a variable whose value is the result of the function that returns the lowest value of a series of values ​​that are received by parameter.
echo min(2, 3, 1, 6, 7);
echo"<br><br>";
echo min(array(2, 4, 5));
echo"<br><br>";

//Define a variable whose value is the result of the function that returns a random number
echo rand() . "\n";
echo rand() . "\n";
echo rand(5, 15);
echo"<br><br>";

?>

56 changes: 56 additions & 0 deletions operators.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
// Operators -, +, *, /, %

var_dump(1 + 1);
echo "<br><br>";
var_dump(1 - 1);
echo "<br><br>";
var_dump(1 * 2);
echo "<br><br>";
var_dump(10 / 5);
echo "<br><br>";
var_dump(10 % 1);
echo "<br><br>";

// Create a usage example for comparison operators: ==,! =, <,>, <=,> =
var_dump(1 == TRUE);
var_dump(0 != FALSE);
var_dump(10 > 9);
var_dump(7 < 8);
echo "<br><br>";
$hi = (object) ["hi" => "hi"];
$biy = (object) ["biy" => "biy"];
echo $hi <=> $biy;
echo "<br><br>";

// Create an example of use for logical operators: &&, And; ||, Or; ! (NOT); Xor

$o = true && false;
var_dump($o);
$y = false && true;
var_dump($y);
$z = true && true;
var_dump($z);
$r = false && false;
var_dump($r);
$q = true || false;
var_dump($q);
$l = false || true;
var_dump($l);
$d = true || true;
var_dump($d);
$s = false || false;
var_dump($s);
echo "<br><br>";


$var='10am';
if($var !='12pm'){
echo 'Get To Work';
}else{
echo 'Break Time!';
}
?>



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

// Print permite imprimir un solo resultado, se permite añadir los etiquetas

print "<h1> Mi codigo PHP - print </h1>";

//Echo permite imprimir varios resultadoe

echo "<p> Mi primer codigo PHP - echo </p>", "<h3> Mi segundo codigo PHP - echo </h3>";

// imprimen los detalles de una variable

$letKnow = array( 5, 0.0, "Hola", false, '' );
print_r($letKnow);
echo "<br><br>";

// imprimen los detalles de una variable con el typo de datos

var_dump($letKnow);

?>

Loading