PHP Interview Questions & Answers part 7

Q: – How would you create a “for” statement that increments through and prints every odd number between 1 and 49?

for ($num = 1; $num <= 49; $num += 2) {
echo "$num<br>";

Q: – What function would you use to join two arrays?


Q: –What function would you use to extract a substring from a string?

The substr() function extracts and returns a substring.

Q: – If a function doesn't require an argument, you can omit the parentheses in the function call. True or False?


Q: – How do you return a value from a function?

Use the return keyword.

Q: – What is a Function?

A function is a self-contained block of code that can be called by your scripts.

Q: – What construct can you use to define an array?


Q: –How might you remove white space from the beginning of a string?

The ltrim() function removes white space from the start of a string.

Q: – Can you include a function call within a double- or single-quoted string, as you can with a variable?

No. You must call functions outside quotation marks.

Submitted By:-Payal Gupta            Email-ID: –