Week 2 Assignment — Variables & Data Types (PHP CLI)

Title: Hello Variables
Due Date: Sept 3, 2025

Goal

Practice basic PHP variables, concatenation, and simple arithmetic in the command line.

Instructions

Beginner (Full Credit)

Create a file week2.php that:

  1. Defines a string variable with your name (e.g., $name = "Alex";).
  2. Prints a concatenation of "Hello world, " and your variable.
    • Example output:
      Hello world, Alex
      
  3. Defines two number variables (e.g., $a = 7; $b = 5;).
  4. Prints the sum of those two numbers.
    • Example output:
      The sum of 7 and 5 is 12
      

Advanced (Optional)

Add one of the following for practice:

  • Store your variables in an array and loop through them to print values.
  • Use an associative array with keys like "name" or "age" and print them.

Turn In

  • Upload your week2.php file to the LMS.
  • Include a screenshot of running php week2.php in your VM terminal.

Rubric (Full Credit: Beginner Only)

| Criterion | Points | ||–| | Defines a string variable with a name | 2 pts | | Prints "Hello world, <name>" using concat | 3 pts | | Defines two number variables | 2 pts | | Correctly prints their sum | 3 pts | | Total | 10 |

Optional advanced work will be noted as “exceeds expectations” but is not required for full credit.