From c318b095803795ff3325cade90147eb33e4f7759 Mon Sep 17 00:00:00 2001 From: Giovanni Di Grezia Date: Sat, 25 Oct 2014 15:24:01 +0200 Subject: [PATCH] esercizi in php --- footer.html | 5 ++++ header.html | 17 +++++++++++ php4.php | 62 ++++++++++++++++++++++++++++++++++++++++ php_1.php | 15 ++++++++++ php_1_2.php | 50 ++++++++++++++++++++++++++++++++ php_1_3.php | 48 +++++++++++++++++++++++++++++++ php_1_4.php | 53 ++++++++++++++++++++++++++++++++++ php_1_5.php | 76 +++++++++++++++++++++++++++++++++++++++++++++++++ php_2.php | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++ php_3.php | 40 ++++++++++++++++++++++++++ 10 files changed, 448 insertions(+) create mode 100644 footer.html create mode 100644 header.html create mode 100644 php4.php create mode 100644 php_1.php create mode 100644 php_1_2.php create mode 100644 php_1_3.php create mode 100644 php_1_4.php create mode 100644 php_1_5.php create mode 100644 php_2.php create mode 100644 php_3.php diff --git a/footer.html b/footer.html new file mode 100644 index 0000000..4168327 --- /dev/null +++ b/footer.html @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/header.html b/header.html new file mode 100644 index 0000000..552a4bf --- /dev/null +++ b/header.html @@ -0,0 +1,17 @@ + + + + Esercizi + + + + + + + + + + + + + diff --git a/php4.php b/php4.php new file mode 100644 index 0000000..93dc0fe --- /dev/null +++ b/php4.php @@ -0,0 +1,62 @@ + 0, 'beta'=> 1,'gamma' =>3); +print_r($b); + +foreach ($a as $key => $value) { + echo $key . $value; +} + +foreach ($b as $key => $value) { + echo $key . $value; +} + + +reset($a); +list($key,$value) = each($a); +echo $key , $value; +list($key,$value) = each($a); +echo $key , $value; + +echo"
"; + + +reset($b); +list($key,$value) = each($b); +echo $key , $value; +list($key,$value) = each($b); +echo $key , $value; + + +$c = explode(" ","mario marra bello"); +print_r($c); + + +$d="marco"; +$e="aflio"; +$f="fonzo"; +$k= compact('d','e','f'); +print_r($k); + + +$j= extract($k,EXTR_PREFIX_ALL,"XG"); +echo $XG_d; + + +$x= str_split("mario"); + +unset($x); +foreach( count_chars("mario",1) as $key => $desc ){ + $x[chr($key)] = $desc; +} +print_r($x); + + + + ?> + + diff --git a/php_1.php b/php_1.php new file mode 100644 index 0000000..a896197 --- /dev/null +++ b/php_1.php @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/php_1_2.php b/php_1_2.php new file mode 100644 index 0000000..577898a --- /dev/null +++ b/php_1_2.php @@ -0,0 +1,50 @@ + + + +table,td { +border:1px solid black; + +} + + + + +_css; + + +$counter_x; +$counter_y; + + +echo ""; + +for ($counter_x = 1 ;$counter_x <= 10; $counter_x++) +{ + echo ''; + for ($counter_y = 1 ;$counter_y <= 10; $counter_y++) + { + echo ''; + + + + } + echo ''; + + +} + + + +echo "
'; + echo $counter_x * $counter_y; + echo '
"; + + + +include ('footer.html'); + ?> \ No newline at end of file diff --git a/php_1_3.php b/php_1_3.php new file mode 100644 index 0000000..49127b8 --- /dev/null +++ b/php_1_3.php @@ -0,0 +1,48 @@ + + + + + + + + +_css; +echo "\n"; +/////////////////////////// + + + +for ($i=1;$i<=9;$i++){ + + echo "

\n"; + echo "$i : " . fattoriale($i); + + echo "

\n"; + +} + + + +include ('footer.html'); + + +function fattoriale ($input){ + + if ($input == 1){ + return 1; + } else { + return (fattoriale($input -1 ) * $input); + } + +} + + + + ?> \ No newline at end of file diff --git a/php_1_4.php b/php_1_4.php new file mode 100644 index 0000000..f98829d --- /dev/null +++ b/php_1_4.php @@ -0,0 +1,53 @@ + + + + + + + + +_css; +echo "\n"; +/////////////////////////// + +echo ""; + +$value = 0; + +for ($i=1;$i<=5;$i++){ + + echo ""; + for ($y=1;$y<=4;$y++){ + + echo ""; + + + } + + echo ""; + + +} + +echo "
"; + + echo ++$value; + + + echo"
"; + + + +include ('footer.html'); + + + + + ?> \ No newline at end of file diff --git a/php_1_5.php b/php_1_5.php new file mode 100644 index 0000000..b42a5fa --- /dev/null +++ b/php_1_5.php @@ -0,0 +1,76 @@ + + + +table {border: 1px solid black;} + +td { + border: 1px solid black; + text-align:center; +} + +table tr:nth-child(3n+2) { + background-color:green; +} +table tr:nth-child(3n+3) { + background-color:pink; +} +table tr:nth-child(3n+4) { + background-color:red; +} + +tr#first { + background-color:yellow; +} + + + + +_css; +echo "\n"; +/////////////////////////// + +echo ""; + +echo ""; + +for ($i=1;$i<=12;$i++){ + + echo ""; + for ($y=1;$y<=2;$y++){ + + echo ""; + + + } + + echo "\n"; + + +} + +echo "
Numero Riga
"; + + if ($y == 1){ + echo $i; + } else { + echo "riga " . $i; + } + + + echo"
"; + + + +include ('footer.html'); + + + + + ?> \ No newline at end of file diff --git a/php_2.php b/php_2.php new file mode 100644 index 0000000..4a91519 --- /dev/null +++ b/php_2.php @@ -0,0 +1,82 @@ + + + + + + + +_css; +echo "\n"; +/////////////////////////// + + +$stringa = "alfio"; +echo "$stringa\n"; +echo "
"; + +$vocali = 0; +$consonanti = 0; +$acharacter=0; +$numeri = 0; + +for ($i=0;$i< strlen($stringa);$i++){ + + $character = substr("$stringa", $i, 1); + switch ($character) { + case "a": + $vocali++; + $acharacter++; + break; + case "e": + $vocali++; + break; + case "i": + $vocali++; + break; + case "o": + $vocali++; + break; + case "u": + $vocali++; + break; + default : + if (is_numeric($character)){ + $numeri++; + + } else{ + $consonanti++; + } + } + + +} + +echo "vocali: $vocali\n"; +echo "
"; +echo "consonanti: $consonanti\n"; +echo "
"; +echo "a character: $acharacter\n"; +echo "
"; +echo "numeri: $numeri\n"; +echo "
"; + +foreach( count_chars($stringa,1) as $key => $desc ){ + echo chr($key) . " ripetuta " . $desc . "volte/n"; + echo"
"; +} + + + +include ('footer.html'); + + + + + ?> \ No newline at end of file diff --git a/php_3.php b/php_3.php new file mode 100644 index 0000000..c72e5e0 --- /dev/null +++ b/php_3.php @@ -0,0 +1,40 @@ + + + + + + + +_css; +echo "\n"; +/////////////////////////// + +if ($_GET == null){ + + + +} else { + + + echo "cioa"; +} + + + + + + + +include ('footer.html'); + + + + + ?> \ No newline at end of file