- Hello World
Write a PHP script that outputs "Hello, World!" using the `echo` statement.
Requirements
- - The script should output "Hello, World!" when executed.
Input
(No input is required for this task)
Expected Output
Hello, World!
📚 View Solution
- Simple Arithmetic
Write a PHP script that calculates the sum, difference, and product of two numbers and prints the results.
Requirements
- - Use the variables `$a` and `$b` to store numbers.
- Output the sum, difference, and product of `$a` and `$b`.
Input
$a = 5;
$b = 3;
Expected Output
Sum: 8
Difference: 2
Product: 15
📚 View Solution
- If-Else Condition
Write a PHP script that checks if a number is positive, negative, or zero, and prints an appropriate message.
Requirements
- - Use an `if-else` statement to check if the number is positive, negative, or zero.
- Output the correct message for each case.
Input
$num = -3;
Expected Output
The number is negative.
📚 View Solution
- String Manipulation
Write a PHP script that accepts a string and prints the following:
- The string in all uppercase.
- The string in all lowercase.
- The length of the string.
Requirements
- - Use `strtoupper()`, `strtolower()`, and `strlen()` functions.
Input
$str = "Hello PHP!";
Expected Output
Uppercase: HELLO PHP!
Lowercase: hello php!
Length: 10
📚 View Solution
- For Loop Example
Write a PHP script that uses a `for` loop to print numbers from 1 to 10.
Requirements
- - Use a `for` loop to iterate from 1 to 10.
- Print each number in a new line.
Input
(No input is required for this task)
Expected Output
1
2
3
4
5
6
7
8
9
10
📚 View Solution