دورة php للمبتدئين الدرس الثامن
1- ل boucle while ف php
// echo 'oui';
// }
// $x = 8;
// $y = 8;
// if($x !== $y){
// echo 'oui';
// }
// $x = 8;
// echo $x--;
// echo --$x;
// $x = 8;
// $y = 8;
// if($x == 8 && $y == 8){
// echo 'oui';
// }
// $x = 8;
// $y = 8;
2- ل boucle for ف php
//index.php
<?php
// $nom = 'samadi';
// echo $nom;
// $age = 20;
// echo $age;
// $note = 15.45;
// echo $note;
// $mineur = false;
// $majeur = true;
// $nom = "samadi";
// function getNom(){
// $nom = "alaoui";
// }
// $names = array('samadi','amine','hassan','adil');
// class Person{
// function Person(){
// return $this->nom = 'samadi';
// }
// }
// $person = new Person();
// echo $person->nom;
// $string = 'la vie est belle';
// echo strlen($string);
// $string = 'la vie est belle';
// echo strpos($string,'belle');
// $string = "la vie est belle";
// echo str_replace("la vie","ma fille",$string);
// define('NOM','samadi');
// echo NOM;
// $nom = 'samadi';
// echo $nom;
// $x = 18;
// $y = 8;
// echo $x*=$y;
// $x = 18;
// $y = 8;
// echo $x/=$y;
// $x = 8;
// $y = 8;
// if($x === $y){
// echo 'oui';
// }
// $x = 8;
// $y = 8;
// if($x != $y){
// echo 'oui';
// }
// $x = 8;
// $y = 8;
// if($x !== $y){
// echo 'oui';
// }
// $x = 8;
// echo $x++;
// echo ++$x;
//index.php
// $nom = 'samadi';
// echo $nom;
// $age = 20;
// echo $age;
// $note = 15.45;
// echo $note;
// $mineur = false;
// $majeur = true;
// $nom = "samadi";
// function getNom(){
// $nom = "alaoui";
// }
// $names = array('samadi','amine','hassan','adil');
// class Person{
// function Person(){
// return $this->nom = 'samadi';
// }
// }
// $person = new Person();
// echo $person->nom;
// $string = 'la vie est belle';
// echo strlen($string);
// $string = 'la vie est belle';
// echo strpos($string,'belle');
// $string = "la vie est belle";
// echo str_replace("la vie","ma fille",$string);
// define('NOM','samadi');
// echo NOM;
// $nom = 'samadi';
// echo $nom;
// $x = 18;
// $y = 8;
// echo $x*=$y;
// $x = 18;
// $y = 8;
// echo $x/=$y;
// $x = 8;
// $y = 8;
// if($x === $y){
// echo 'oui';
// }
// $x = 8;
// $y = 8;
// if($x != $y){
// echo 'oui';
// }
// $x = 8;
// $y = 8;
// if($x !== $y){
// echo 'oui';
// }
// $x = 8;
// echo $x--;
// echo --$x;
// $x = 8;
// $y = 8;
// if($x == 8 && $y == 8){
// echo 'oui';
// }
// $x = 8;
// $y = 8;
// if($x == 8 || $y == 8){
// echo 'oui';
// }
// $x = true;
// if(!$x){
// echo 'oui';
// }
// if($x == 8){
// echo 'oui';
// }elseif($x == 6){
// echo 6;
// }else{
// echo 'non';
// }
// switch ($x) {
// case 8:
// echo 8;
// break;
// case 6:
// echo 6;
// break;
// case 7:
// echo 7;
// break;
// default:
// echo "Aucun résultat";
// }
// $x = 1;
// while($x <= 10){
// echo $x.'<br/>';
// $x++;
// }
for($i=0;$i<=10;$i++){
echo $i;
}
?>
3- ل boucle do while ف php
//index.php
<?php
// $nom = 'samadi';
// echo $nom;
// $age = 20;
// echo $age;
// $note = 15.45;
// echo $note;
// $mineur = false;
// $majeur = true;
// $nom = "samadi";
// function getNom(){
// $nom = "alaoui";
// }
// $names = array('samadi','amine','hassan','adil');
// class Person{
// function Person(){
// return $this->nom = 'samadi';
// }
// }
// $person = new Person();
// echo $person->nom;
// $string = 'la vie est belle';
// echo strlen($string);
// $string = 'la vie est belle';
// echo strpos($string,'belle');
// $string = "la vie est belle";
// echo str_replace("la vie","ma fille",$string);
// define('NOM','samadi');
// echo NOM;
// $nom = 'samadi';
// echo $nom;
// $x = 18;
// $y = 8;
// echo $x*=$y;
// $x = 18;
// $y = 8;
// echo $x/=$y;
// $x = 8;
// $y = 8;
// if($x === $y){
// echo 'oui';
// }
// $x = 8;
// $y = 8;
// if($x != $y){
// echo 'oui';
// }
// $x = 8;
// $y = 8;
// if($x !== $y){
// echo 'oui';
// }
// $x = 8;
// echo $x++;
// echo ++$x;
//index.php
// $nom = 'samadi';
// echo $nom;
// $age = 20;
// echo $age;
// $note = 15.45;
// echo $note;
// $mineur = false;
// $majeur = true;
// $nom = "samadi";
// function getNom(){
// $nom = "alaoui";
// }
// $names = array('samadi','amine','hassan','adil');
// class Person{
// function Person(){
// return $this->nom = 'samadi';
// }
// }
// $person = new Person();
// echo $person->nom;
// $string = 'la vie est belle';
// echo strlen($string);
// $string = 'la vie est belle';
// echo strpos($string,'belle');
// $string = "la vie est belle";
// echo str_replace("la vie","ma fille",$string);
// define('NOM','samadi');
// echo NOM;
// $nom = 'samadi';
// echo $nom;
// $x = 18;
// $y = 8;
// echo $x*=$y;
// $x = 18;
// $y = 8;
// echo $x/=$y;
// $x = 8;
// $y = 8;
// if($x === $y){
// echo 'oui';
// }
// $x = 8;
// $y = 8;
// if($x != $y){
// echo 'oui';
// }
// $x = 8;
// $y = 8;
// if($x !== $y){
// echo 'oui';
// }
// $x = 8;
// echo $x--;
// echo --$x;
// $x = 8;
// $y = 8;
// if($x == 8 && $y == 8){
// echo 'oui';
// }
// $x = 8;
// $y = 8;
// if($x == 8 || $y == 8){
// echo 'oui';
// }
// $x = true;
// if(!$x){
// echo 'oui';
// }
// if($x == 8){
// echo 'oui';
// }elseif($x == 6){
// echo 6;
// }else{
// echo 'non';
// }
// switch ($x) {
// case 8:
// echo 8;
// break;
// case 6:
// echo 6;
// break;
// case 7:
// echo 7;
// break;
// default:
// echo "Aucun résultat";
// }
// $x = 1;
// while($x <= 10){
// echo $x.'<br/>';
// $x++;
// }
// for($i=0;$i<=10;$i++){
// echo $i;
// }
$x = 1;
do{
echo $x;
$x++;
}while($x <= 10);
?>
4- ل boucle foreach ف php
//index.php
<?php
// $nom = 'samadi';
// echo $nom;
// $age = 20;
// echo $age;
// $note = 15.45;
// echo $note;
// $mineur = false;
// $majeur = true;
// $nom = "samadi";
// function getNom(){
// $nom = "alaoui";
// }
// $names = array('samadi','amine','hassan','adil');
// class Person{
// function Person(){
// return $this->nom = 'samadi';
// }
// }
// $person = new Person();
// echo $person->nom;
// $string = 'la vie est belle';
// echo strlen($string);
// $string = 'la vie est belle';
// echo strpos($string,'belle');
// $string = "la vie est belle";
// echo str_replace("la vie","ma fille",$string);
// define('NOM','samadi');
// echo NOM;
// $nom = 'samadi';
// echo $nom;
// $x = 18;
// $y = 8;
// echo $x*=$y;
// $x = 18;
// $y = 8;
// echo $x/=$y;
// $x = 8;
// $y = 8;
// if($x === $y){
// echo 'oui';
// }
// $x = 8;
// $y = 8;
// if($x != $y){
// echo 'oui';
// }
// $x = 8;
// $y = 8;
// if($x !== $y){
// echo 'oui';
// }
// $x = 8;
// echo $x++;
// echo ++$x;
//index.php
// $nom = 'samadi';
// echo $nom;
// $age = 20;
// echo $age;
// $note = 15.45;
// echo $note;
// $mineur = false;
// $majeur = true;
// $nom = "samadi";
// function getNom(){
// $nom = "alaoui";
// }
// $names = array('samadi','amine','hassan','adil');
// class Person{
// function Person(){
// return $this->nom = 'samadi';
// }
// }
// $person = new Person();
// echo $person->nom;
// $string = 'la vie est belle';
// echo strlen($string);
// $string = 'la vie est belle';
// echo strpos($string,'belle');
// $string = "la vie est belle";
// echo str_replace("la vie","ma fille",$string);
// define('NOM','samadi');
// echo NOM;
// $nom = 'samadi';
// echo $nom;
// $x = 18;
// $y = 8;
// echo $x*=$y;
// $x = 18;
// $y = 8;
// echo $x/=$y;
// $x = 8;
// $y = 8;
// if($x === $y){
// echo 'oui';
// }
// $x = 8;
// $y = 8;
// if($x != $y){
// echo 'oui';
// }
// $x = 8;
// $y = 8;
// if($x !== $y){
// echo 'oui';
// }
// $x = 8;
// echo $x--;
// echo --$x;
// $x = 8;
// $y = 8;
// if($x == 8 && $y == 8){
// echo 'oui';
// }
// $x = 8;
// $y = 8;
// if($x == 8 || $y == 8){
// echo 'oui';
// }
// $x = true;
// if(!$x){
// echo 'oui';
// }
// if($x == 8){
// echo 'oui';
// }elseif($x == 6){
// echo 6;
// }else{
// echo 'non';
// }
// switch ($x) {
// case 8:
// echo 8;
// break;
// case 6:
// echo 6;
// break;
// case 7:
// echo 7;
// break;
// default:
// echo "Aucun résultat";
// }
// $x = 1;
// while($x <= 10){
// echo $x.'<br/>';
// $x++;
// }
// for($i=0;$i<=10;$i++){
// echo $i;
// }
// $x = 1;
// do{
// echo $x;
// $x++;
// }while($x <= 10);
$names = array("adil", "samir", "hassan", "amine");
foreach ($names as $value) {
echo "$value <br>";
}
?>