diff --git a/arrays.php b/arrays.php new file mode 100644 index 0000000..1a20beb --- /dev/null +++ b/arrays.php @@ -0,0 +1,36 @@ +"; + + //Execute the function that allows to obtain the length of an array +echo (count( $motorcycles)); + +//Execute the function that allows to obtain the combination of two arrays +$colors1 = array('green', 'red', ' yellow'); +$colors = array('green', 'red', ' yellow'); +$c = array_combine($colors1, $colors); + + +//Execute the function that once is given an array return the last element of it +echo end($colors1); + +//Execute the function that once is given an array add a new element to the array in question +$phones = array("apple", "samsung"); +array_push($phones, "huawei", "xiaomi"); +print_r($phones); + + +?> \ No newline at end of file diff --git a/conditionals.php b/conditionals.php new file mode 100644 index 0000000..f86e304 --- /dev/null +++ b/conditionals.php @@ -0,0 +1,65 @@ +"; +//Create a double condition that evaluates: if the current minute is less than 10, +//Displays a message of type "the current minute is less than 10", if the current minute is greater than 15, +// displays a message of the type "the current minute is more than 15", +// If you do not meet any of the two conditions above: Displays a message of the type +// "does not meet any conditions” + +$currentMinute = date("i"); +if ($currentMinute < 10) { +echo " the current minute is less than 10"; +} elseif ($currentMinute > 15) { + echo " the current minute is more than 15"; +} else { + echo " does not meet any conditions"; +} + +echo "
"; + +//Create a switch type control structure to display a different message depending on the current day of the +// week. You can write any type of message because the important thing is that you understand how it works +// and in what cases you can use it. + +$day = date('l'); +switch ($day) { + case 'Monday': + echo " $day"; + break; + case 'Tuesday': + echo " $day"; + break; + case 'Wednesday': + echo " $day"; + break; + case 'Thursday': + echo " $day"; + break; + case 'Friday': + echo " $day"; + break; + case 'Saturday': + echo " $day"; + break; + case 'Sunday': + echo " $day"; + break; +} +?> \ No newline at end of file diff --git a/dates.php b/dates.php new file mode 100644 index 0000000..0c449d3 --- /dev/null +++ b/dates.php @@ -0,0 +1,10 @@ +"; +echo date( format: "D" ); +echo "
"; +echo date( format: "m"); +echo "
"; +echo date( 'i' ); +?> \ No newline at end of file diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..318563d --- /dev/null +++ b/functions.php @@ -0,0 +1,43 @@ + \ No newline at end of file diff --git a/iterators.php b/iterators.php new file mode 100644 index 0000000..586daf5 --- /dev/null +++ b/iterators.php @@ -0,0 +1,26 @@ +"; +} + +$array = ["a", "bb", "ccc"]; +forEach($array as $value){ + print "

$value

\n"; +} + +$a= 5; +while($a<=20): + echo $a."
"; + $a++; +endwhile; + + $b=1; + do{ + echo $b."
"; + $b++; + }while($b<=8); + + +?> \ No newline at end of file diff --git a/maths.php b/maths.php new file mode 100644 index 0000000..83f6054 --- /dev/null +++ b/maths.php @@ -0,0 +1,23 @@ +"; + + //Define a variable whose value is the result of the function that returns a rounded value to the next highest integer. + $rounded=round(3.4); + echo $rounded."
"; + + //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 + $highest=max([2,3,1,6,7]); + echo $highest."
"; + + //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. + $lowest = min([2,3,1,6,7]); + echo $lowest."
"; + +//Define a variable whose value is the result of the function that returns a random number +$random = rand(10,100); +echo $random + +?> \ No newline at end of file diff --git a/operators.php b/operators.php new file mode 100644 index 0000000..637f3f4 --- /dev/null +++ b/operators.php @@ -0,0 +1,19 @@ +'; + +var_dump($a===$b); +echo '
'; +$c=2; + +var_dump($a && $c ===! 2) + + + + +?> \ No newline at end of file diff --git a/phpinfo.php b/phpinfo.php new file mode 100644 index 0000000..6480abf --- /dev/null +++ b/phpinfo.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/print.php b/print.php new file mode 100644 index 0000000..2bc12ca --- /dev/null +++ b/print.php @@ -0,0 +1,23 @@ +Welcome Php"; +} +welcome(); + +print "

Print imprime solo una cadena de texto

"; + +$arr= [1,2,3,4,5]; +print_r ($arr) + + + + + + + + + + + + +?> \ No newline at end of file diff --git a/strings.php b/strings.php new file mode 100644 index 0000000..b204208 --- /dev/null +++ b/strings.php @@ -0,0 +1,44 @@ +"; + +//Print a text string that interpret variables +$hi= "Hello"; +$bye= "Good bye"; +echo $hi."
"; + +//Concatenate a previously declared variable in a text string +echo $hi ."Mi nombre es Sofia
"; + +//Execute the function that allows you to replace text in a string +$replace = str_replace("Php", $hi, $bye); +echo $replace; + +//Execute the function that allows you to replace text in a string (without taking into account upper / lower case) +$replaceNoSensitive = str_ireplace("php", $hi, $bye); +echo $replaceNoSensitive."
"; + +//Execute the function that allows you to write a text N times +echo str_repeat(" Argentina Campeón Mundial ", 10)."
"; + +//Execute the function that allows to obtain the length of a text string +$str = 'Happy New Year'; +echo strlen($str)."
"; + + +//Executes the function that allows to obtain the position of the first occurrence of a text within a text string +echo strpos("I love Messi so much","Messi")."
"; + +//Execute the function that allows a text string to be capitalized +$upper = $bye." in upper"; +echo strtoupper($upper)."
"; + +//Execute the function that allows you to transform a text string to lowercase +$lower = " My name is Sofi "; +$lower = strtolower($lower); +echo $lower."
"; + +//Execute the function that allows to obtain a text substring from the position +echo substr('sofia', 3, -1); + +?> \ No newline at end of file diff --git a/types.php b/types.php new file mode 100644 index 0000000..7c781e8 --- /dev/null +++ b/types.php @@ -0,0 +1,19 @@ + 'value'); +$variableNull= null; + +?> \ No newline at end of file