0% found this document useful (0 votes)
14 views2 pages

PHP Comments

Uploaded by

ethioawashmedia
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)
14 views2 pages

PHP Comments

Uploaded by

ethioawashmedia
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/ 2

PHP Comments

A. PHP Single Line Comments(// )

B. PHP Multi Line Comments(/* */)


Control Structures in PHP
 Conditional Statements
a. if statement

<?php
$x = 10; d. switch statement
if ($x > 0) { <?php
echo "$x is a positive $day = "Monday";
number."; switch ($day) {
} case "Monday":
?> echo "Today is
Monday.";
b. if - else statement break;
case "Tuesday":
<?php echo "Today is
$x = -5; Tuesday.";
if ($x > 0) { break;
echo "$x is a positive case "Wednesday":
number."; echo "Today is
} else { Wednesday.";
echo "$x is a negative break;
number."; case "Thursday":
} echo "Today is
?> Thursday.";
break;
c. if - elseif - else statement case "Friday":
echo "Today is Friday.";
<?php break;
$grade = 85; case "Saturday":
if ($grade >= 90) { echo "Today is
echo "You got an A."; Saturday.";
} elseif ($grade >= 80) { break;
echo "You got a B."; case "Sunday":
} elseif ($grade >= 70) { echo "Today is
echo "You got a C."; Sunday.";
} elseif ($grade >= 60) { break;
echo "You got a D."; default:
} else { echo "Invalid day.";
echo "You got an F."; }
} ?>
?>
 Loop Statements
1. While loop ?>
<?php 3. For loop
$x = 1; <?php
while ($x <= for ($x = 1; $x
10) { <= 10; $x++)
echo "$x "; {
$x++; echo "$x ";
} }
?> ?>
2. Do-while loop 4. Foreach loop
<?php <php
$x = 11; $colors = array("red",
do { "green", "blue");
echo "$x "; foreach ($colors as $color) {
$x++; echo "$color ";
} while ($x <= }
10); ?>

 Jump Statements
<?php
goto a;
echo 'Foo';
a:
echo 'Bar';
?>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy