دورة php للمبتدئين الدرس السادس
1- كيفاش ن incrémenter ف 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;
?>
2- كيفاش ن décrémenter ف 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;
$x = 8;
echo $x--;
echo --$x;
?>
3- les opérateurs logiques ف 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';
}
?>
4- L'OPÉRATEUR || ف PHP
ف || php l'opérateur كيعني or ولي كيمكن باش ن tester بلي واحد من الشروط كاين فالمثال لي عندي كندير test فيه يلا كانت x كتساوي 8 أو y كتساوي 8 كن afficher oui الكود لي زدنا هو:
//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';
}
?>
5- L'OPÉRATEUR ! ف PHP
ف ! php l'opérateur كيعني not ولي كيمكن باش ن tester بلي واحد ل variable كتساوي العكس ديال القيمة ديالها وكنخدموا به ف les booléens فالمثال لي عندي عطيت ل x true منبعد درت test يلا كانت لعكس ديال x يعني x كتساوي false كن afficher oui الكود لي زدنا هو:
//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';
}
?>