Preview

Php Statement & Loop Samples

Better Essays
Open Document
Open Document
989 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Php Statement & Loop Samples
IF STATEMENT

SAMPLE 1
<?php

$studentId = 'A1110601'; if ( $studentId == 'A1110601' ) { echo ' Student ID: '.$studentId.'<br/>'. ' Welcome! Inah Ysabela Marie D. Alegre'; }

?>

SAMPLE 2
<?php

$birthdate = 'April 8, 1995'; if ( $birthdate == 'April 8, 1995' ) { echo ' Birthdate : '.$birthdate; }

?>

SAMPLE 3
<?php

$grade = 86; if ( $grade == 86 ) { echo ' Passed! Your grade is '.$grade; }

?>

SAMPLE 4
<?php

$employee = 'Mary Jane Santos'; if ( $employee == 'Mary Jane Santos' ) { echo $employee.' you are hired! '; }

?>

SAMPLE 5
<?php

$university = 'University of Makati' ;

if ( $university == 'University of Makati' ) { echo 'I am studying at '.$university; }

?>

IF … ELSE STATEMENT

SAMPLE 1
<?php

$gender = 'Female'; if ($gender == 'Female')
{
echo ' Beautiful lady';
}
else
{
echo ' Handsome man';
}

?>

SAMPLE 2
<?php

$grade = 65; if ($grade >= 80)
{
echo 'Congratulations, you passed!';
}
else
{
echo ' Sorry, you failed!';
}

?>

SAMPLE 3
<?php

$items = 125; if ($items >= 100)
{
echo ' Over stock!';
}
else
{
echo ' Out-of-stock!';
}

?>

SAMPLE 4
<?php

$num = 19; if ($num % 2 == 0)
{
echo ' Number is Even!';
}
else
{
echo ' Number is Odd!';
}

?>

SAMPLE 5
<?php

$age = 36 ; if ($age >= 30)
{
echo ' You are an adult.';
}
else
{
echo ' You are a teenager.';
}

?>

IF … ELSE IF … ELSE STATEMENT

SAMPLE 1
<?php

$mysteryGift = ‘choice2’; if ( $mysteryGift == ‘choice1’ ) { echo ‘A brown teddy bear.’; } elseif ( $mysteryGift == ‘choice2’ ) { echo ‘A pink rabbit.’; } else { echo ‘A white panda.’; } ?>

SAMPLE 2
<?php

$order = ‘2 choco honey dip’; if ( $order == ‘2 choco honey dip’ ) { echo ‘Your bill is 40.00 ‘; } elseif (

You May Also Find These Documents Helpful

  • Satisfactory Essays

    a1 script win213

    • 380 Words
    • 2 Pages

    If the user does not enter a numeric value the program should prompt for a numeric value…

    • 380 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    PT1420 Unit 8 Lab 8

    • 365 Words
    • 2 Pages

    Step 6: Explain what you think will be displayed to the screen in Step 5. (Reference:…

    • 365 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    It210 Week 4 Psuedocode

    • 584 Words
    • 3 Pages

    = Yes || yes|| No || no Write: “That is not a correct entry!” Write: “Please enter Yes or No.” Input QuitNow…

    • 584 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Unit 7 Assignment 1

    • 261 Words
    • 2 Pages

    2. A pretest loop is a loop tests the conditions before performing the iteration. A posttest loop performs the iteration then test the condition.…

    • 261 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    It 210 Checkpoint

    • 374 Words
    • 2 Pages

    In one of the week 3 discussion questions we discussed the algorithm that would be required to make a peanut butter sandwich. In this CheckPoint you will need to take that one step further and create a program design to make a peanut butter sandwiches. Below you will find a partial program design; you need to complete it by adding the pseudocode in the required areas. You need to add one repetition (loop) control structure and one decision control to complete the program design. The user will decide how many sandwiches are made; this is where the loop will be used. The user will decide if the sandwich includes jelly, and, if it does, what flavor of jelly; to keep it simple we are only allowing grape or strawberry jelly.…

    • 374 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Comp230 Wk 5 Lab

    • 411 Words
    • 2 Pages

    Copy your Mod1_PCTests.vbs program from NotePad++ and paste it into the space provided below. Any portion of the script that will not fit should be continued in the textbox on the next page.…

    • 411 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    PT1420 Unit 3 Labs

    • 270 Words
    • 2 Pages

    The Network Systems Administration degree is awarded after 90 credits and Nolan Owen has 70 left to take before graduation.…

    • 270 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Week 9 Eng 101 Checkpoint

    • 326 Words
    • 2 Pages

    Enter the correct answer for each item by typing either a or b in the second column. Provide an explanation for each choice in the Rationale column. The boxes expand to accommodate your text.…

    • 326 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    To make sure that we can identify your exam if your student ID number is hard to read, please tick the boxes below to fill in your seven digit student ID number. Detailed instructions are on the next page. 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0…

    • 6053 Words
    • 25 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Comp230 W2 Ilab

    • 1120 Words
    • 5 Pages

    Student Name | | Class | Comp230 | Date | 5/16/2013 | VBScript IPO VBox Lab Report ' VBScript: NameAge.vbs ' Written by: ' Date: 5/16/2013 ' Class: Comp230 ' Professor: Giao Dau ' = == == == ==…

    • 1120 Words
    • 5 Pages
    Satisfactory Essays
  • Good Essays

    C) one value when the condition is true and another value when the condition is false…

    • 1829 Words
    • 8 Pages
    Good Essays
  • Satisfactory Essays

    It 210 Week 7

    • 286 Words
    • 2 Pages

    2. Display the contents of the file GRADES created in Problem 1. Each student’s record should appear on a separate line and include the total score (the sum of the three tests) for that student. For example, a line of output might be as follows:…

    • 286 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    This Is a Paper

    • 469 Words
    • 2 Pages

    Consider the following selection statement where X is an integer test score between 0 and 100.…

    • 469 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Lab 3 Student

    • 1264 Words
    • 7 Pages

    Step 1: This program is most easily solved using just a few variables. Identify potential problems with the following variables declared in the pseudocode. Assume that the college has the ability to offer half credits. (Reference: Variable Names, page 39-40).…

    • 1264 Words
    • 7 Pages
    Satisfactory Essays
  • Powerful Essays

    Hangman Script

    • 487 Words
    • 2 Pages

    3 ) echo "peguin" ;; 4 ) echo "awesome" ;; 5 ) echo "ubuntu" ;;…

    • 487 Words
    • 2 Pages
    Powerful Essays