1 / 7

PHP

PHP. http://www.w3schools.com/php / http://php.net/manual/ro/index.php. Primul PHP. <? php echo "Hello! Marinel "; ?>. Primul form. index.html. <html > < body > < form action="action.php" method="post"> < p>Your name: <input type="text" name="name" /></p >

roscoe
Télécharger la présentation

PHP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PHP http://www.w3schools.com/php/ http://php.net/manual/ro/index.php

  2. Primul PHP <?php echo "Hello! Marinel"; ?>

  3. Primul form index.html <html> <body> <form action="action.php" method="post"> <p>Your name: <input type="text" name="name" /></p> <p>Your age: <input type="text" name="age" /></p> <p><input type="submit" /></p> </form> </body> </html> action.php <?php echo "Hi ", $_POST['name'], "<br>"; echo "You are ", $_POST['age'], " years old."; ?>

  4. Generator numere prime generator_2.php <html> <head> <title>Generator de numere prime</title> </head> <body> <h1>Generator de numere prime in linie</h1> <?php if(isset($_POST['contor'])) { $contor=$_POST['contor']; echo "Generezprimele ", $contor, " numere prime:<br><br>"; echo "2"; $i=1; $nr=3; while ($i < $contor) { $sqrt=(int) sqrt($nr); $prim=1; for ($j=3; $j<=$sqrt; $j=$j+2) { if ($nr % $j == 0) { $prim=0; break; } } if ($prim==1) { echo ", ", $nr; $i++; } $nr = $nr + 2; } } else { ?> <form name="input" action="" method="POST"> <p> Genereazaprimele <input type="number" name="contor" min="1" max="10000" /> numere prime. </p> <input type="submit" value="Genereaza!" /> </form> <?php } ?> </body> </html>

  5. generator_3.php Generator numere prime <html><head> <title>Generator de numere prime</title> </head> <body> <h1>Generator de numere prime in tabel</h1> <?php if(isset($_POST['contor'])) { $contor=$_POST['contor']; $coloane=$_POST['coloane']; echo "Generezprimele ", $contor, " numere prime:<br><br>"; ?> <table border = '2'> <tr> <td>2</td> <?php $i=1; $nr=3; while ($i < $contor) { $sqrt=(int) sqrt($nr); $prim=1; for ($j=3; $j<=$sqrt && $nr%j; $j=$j+2); if ($j>$sqrt{ echo "<td>", $nr, "</td>"; $i++; if ($i % $coloane == 0) echo "</tr> <tr>"; } $nr = $nr + 2; } ?> </tr > </table> <?php } else { ?> <form name="input" action="" method="POST"> <p> Primele<input type="number" name="contor" min="1" max="10000" /> numere prime </p> <p> pe <input type="number" name="coloane" min="1" max="20" /> coloane. </p> <input type="submit" value="Genereaza!" /> </form> <?php } ?> </body></html>

  6. calculator_medii.php <html> <head> <title> Calculator de medii</title> </head> <body> <h1>Calculator de medii</h1> <?php if(isset($_POST['contor'])) { //Trebuiesagenerezcampuri $contor= $_POST['contor']; ?> <form name="input" action="" method="POST"> <?php for ($i=1; $i<=$contor; $i++) echo "<p> Media numarul " . $i . " este <input type='number' name='media" . $i ."' min='1' max='10' step='0.01' /> </p>"; ?> <input type="submit" value="Calculeaza!" /> </form> <?php } else if(isset($_POST['media1'])) { //Am primitmediile, voicalculasiafisamedia $i=1; $suma=0; while (isset($_POST["media" . $i])) { $suma+=$_POST["media" . $i]; $i++; } echo "Media generala a notelorintroduseeste " . ($suma/($i-1)); } else { ?> <form name="input" action="" method="POST"> <p> Vreausaintroduc <input type="number" name="contor" min="1" max="20" step="1" /> medii. </p> <input type="submit" value="Introdu!" /> </form> <?php } ?> </body> </html> Calculator medii

  7. Contorizarecuvinteşi caractere <html> <head> <title>Siruri de caractere</title> </head> <body> <h1>Siruri de caractere</h1> <?php if(isset($_POST['text'])) { $text=$_POST['text']; $lungime = strlen ($text); echo $text , "<br><hr><br>"; echo "Lungimeatextuluintroduseste de " , $lungime, " caractere! </br>"; $cuvinte= 0; for ($i=0; $i <=$lungime; $i++) { if ($text[$i] == ' ' || $text[$i] == '\n' || $text[$i] == '\t' ) $cuvinte++; } echo "Textul are " , $cuvinte, " cuvinte!</br>"; $cuvinte1=0; $tok = strtok($text, " \n\t"); while ($tok !== false) { $cuvinte1++; $tok = strtok(" \n\t"); } echo "Textul are " , $cuvinte1, " cuvinte (cu strtok)!</br>"; } else { ?> <form name="input" action="" method="POST"> <p> Introdu text aici: </p> <textarea name="text" rows="10" cols="40"> </textarea> </br> <input type="submit" value="Numara!" /> </form> <?php } ?> </body> </html> siruri_caractere.php

More Related