0% found this document useful (0 votes)
0 views

use cas php

The document contains a PHP script embedded in an HTML page that demonstrates various programming concepts such as variable declaration, data types, control structures, loops, and switch statements. It includes examples of echoing strings, performing arithmetic operations, and using conditional statements. Additionally, it features a dropdown menu populated with numbers from 0 to 30.

Uploaded by

zarahasnae
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

use cas php

The document contains a PHP script embedded in an HTML page that demonstrates various programming concepts such as variable declaration, data types, control structures, loops, and switch statements. It includes examples of echoing strings, performing arithmetic operations, and using conditional statements. Additionally, it features a dropdown menu populated with numbers from 0 to 30.

Uploaded by

zarahasnae
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

<!

DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<style>
*{
font-size: 30px;
color: red;
text-align: center;
}
</style>
<title>first php page </title>
</head>

<body>
<h1> bonjour html </h1>
<br>
</body>
</html>

<?php

/* echo "<h2> bonjour php </h2> ";

$a="hello";
echo $a ;
echo "<br>";
echo gettype($a);
echo var_dump($a);
$a=100;
echo $a ;
echo "<br>";
echo gettype($a);
echo var_dump($a);
$b="ahmed";
echo "bonjour $b";
echo 'bonjour $b';
echo "<br>";
$b=111;
$c=$a+$b;
echo$c;
echo "<br>";
echo $a.$b;
echo "<br>";
$b='111';
$a='100';
$c=$a+$b;
echo$c;
echo "<br>";
$b="111";
$a="100";
$c=$a+$b;
echo$c;
echo "<br>";
$b=111;
$a="100";
$c=$a+$b;
echo$c;
// les autres operateurs - , * / %
*/
$n=10;
$m='10';
$p="10";
/* define("ct",11111);
echo "<br>";
echo ct; */
$var=$n!==$p;
echo ($var);
var_dump($var);
//Structures de contrôle
// les testes
$n=10;
if($n%2==0) echo"n est pair";
else echo "n est impair";
echo "<br>";
$m=11;
// operateur ternaire
echo($n%2==0)?("m est pair"):("m est impair");
echo "<br>";

?>

<?php
// Variable = (Condition) ? (Statement1) : (Statement2);
$a = 10;
$b = $a > 15 ? 20 : 5;
print ("Value of b is " . $b);
echo "<br>";
$a=12;
if ($a%4==0)
echo " a Divisible par 4 et pair 2";
elseif ($a%2==0)
echo " a Divisible par 2";
else echo " a n'est pas divisible par 2";

// les boucles

?>
<?php
for ($x = 0; $x <= 10; $x++) {
echo "The number is: $x <br>";
}

?>
<?php
$x = 1;

while($x <= 5) {
echo "The number x is: $x <br>";
$x++;
}
?>

<?php
$x = 1;

do {
echo "The number is: $x <br>";
$x++;
} while ($x <= 5);
?>

<?php
$favcolor = "red";

switch ($favcolor) {
case "red":
echo "Your favorite color is red!";
break;
case "blue":
echo "Your favorite color is blue!";
break;
case "green":
echo "Your favorite color is green!";
break;
default:
echo "Your favorite color is neither red, blue, nor green!";
}

$i=3;
switch ($i)
{
case 1: {echo "Un"; break; }
case 2: {echo "Deux"; break; }
case 3: {echo "Trois"; break;}
default:
echo "Autre valeur";
}

?>
<html>
<body>

<select name="jour" >


<?php for ($i=0; $i < 31; $i++) { ?>

<option > <?php echo $i ?>


</option>
<?php }?>

</select>

Chaîne de caractères

You might also like