0
0
PHPprogramming~10 mins

PHP Installation and Setup - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to display "Hello, World!" in PHP.

PHP
<?php
echo [1];
?>
Drag options to blanks, or click blank then click option'
A'Hello World'
BHello, World!
C"Hello, World!"
DHello World
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the string.
Using echo without a semicolon.
2fill in blank
medium

Complete the code to start a PHP script block.

PHP
[1]
echo "Welcome to PHP!";
?>
Drag options to blanks, or click blank then click option'
A<?
B<?php
C<php>
D<script>
Attempts:
3 left
💡 Hint
Common Mistakes
Using short tags like
Using HTML tags like <script> instead of PHP tags.
3fill in blank
hard

Fix the error in the PHP code to correctly declare a variable.

PHP
<?php
[1] = 10;
echo $number;
?>
Drag options to blanks, or click blank then click option'
A$number
Bvar number
Cint number
Dnumber
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the dollar sign before the variable name.
Trying to declare variable types explicitly.
4fill in blank
hard

Fill both blanks to create an array and print its first element.

PHP
<?php
$fruits = array([1]);
echo $fruits[2];
?>
Drag options to blanks, or click blank then click option'
A"apple", "banana", "cherry"
B[0]
C[1]
D[2]
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong index to access the first element.
Not putting strings inside quotes in the array.
5fill in blank
hard

Fill all three blanks to define a function and call it.

PHP
<?php
function [1]() {
    echo [2];
}

[3]();
?>
Drag options to blanks, or click blank then click option'
Agreet
B"Hello from function!"
DsayHello
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching function name in definition and call.
Forgetting quotes around the string inside echo.