21 real Strings & Functions questions from the PHP bank, as asked in Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd — free to start.
1. What is String interpolation?
Junior
A.the parsing of variable references embedded directly inside a double-quoted or heredoc string so their values are substituted into the output
B.a parameter prefixed with three dots that collects any number of trailing arguments into a single array inside the function
C.a single-expression closure written with the fn keyword that automatically captures variables from the enclosing scope by value
D.passing values to a function by the parameter's name rather than its position, letting callers skip optional defaults and reorder freely
2. Which term means: "the parsing of variable references embedded directly inside a double-quoted or heredoc string so their values are substituted into the output"?
A.String interpolation — the parsing of variable references embedded directly inside a double-quoted or heredoc string so their values are substituted into the output
B.String interpolation — the PHP 8.1 form using three dots in parentheses, such as a method name followed by that token, which creates a Closure referencing the function or method
C.String interpolation — a multi-line string syntax opened with three less-than signs and a single-quoted identifier whose body is treated literally with no variable parsing
D.String interpolation — a parameter prefixed with three dots that collects any number of trailing arguments into a single array inside the function
A.a multi-line string syntax opened with three less-than signs and an identifier whose body still parses embedded variables like a double-quoted string
B.the parsing of variable references embedded directly inside a double-quoted or heredoc string so their values are substituted into the output
C.a single-expression closure written with the fn keyword that automatically captures variables from the enclosing scope by value
D.a parameter prefixed with three dots that collects any number of trailing arguments into a single array inside the function
5. Which term means: "a multi-line string syntax opened with three less-than signs and an identifier whose body still parses embedded variables like a double-quoted string"?
A.Heredoc — a multi-line string syntax opened with three less-than signs and a single-quoted identifier whose body is treated literally with no variable parsing
B.Heredoc — the PHP 8.1 form using three dots in parentheses, such as a method name followed by that token, which creates a Closure referencing the function or method
C.Heredoc — a parameter prefixed with three dots that collects any number of trailing arguments into a single array inside the function
D.Heredoc — a multi-line string syntax opened with three less-than signs and an identifier whose body still parses embedded variables like a double-quoted string
8. Which term means: "a multi-line string syntax opened with three less-than signs and a single-quoted identifier whose body is treated literally with no variable parsing"?
A.Nowdoc — a multi-line string syntax opened with three less-than signs and a single-quoted identifier whose body is treated literally with no variable parsing
B.Nowdoc — a multi-line string syntax opened with three less-than signs and an identifier whose body still parses embedded variables like a double-quoted string
C.Nowdoc — a single-expression closure written with the fn keyword that automatically captures variables from the enclosing scope by value
D.Nowdoc — a parameter prefixed with three dots that collects any number of trailing arguments into a single array inside the function
A.Variadic parameter — a parameter prefixed with three dots that collects any number of trailing arguments into a single array inside the function
B.Variadic parameter — a multi-line string syntax opened with three less-than signs and an identifier whose body still parses embedded variables like a double-quoted string
C.Variadic parameter — a multi-line string syntax opened with three less-than signs and a single-quoted identifier whose body is treated literally with no variable parsing
D.Variadic parameter — a single-expression closure written with the fn keyword that automatically captures variables from the enclosing scope by value
A.a multi-line string syntax opened with three less-than signs and an identifier whose body still parses embedded variables like a double-quoted string
B.a single-expression closure written with the fn keyword that automatically captures variables from the enclosing scope by value
C.the parsing of variable references embedded directly inside a double-quoted or heredoc string so their values are substituted into the output
D.passing values to a function by the parameter's name rather than its position, letting callers skip optional defaults and reorder freely
14. Which term means: "passing values to a function by the parameter's name rather than its position, letting callers skip optional defaults and reorder freely"?
A.Named arguments — a multi-line string syntax opened with three less-than signs and an identifier whose body still parses embedded variables like a double-quoted string
B.Named arguments — passing values to a function by the parameter's name rather than its position, letting callers skip optional defaults and reorder freely
C.Named arguments — the PHP 8.1 form using three dots in parentheses, such as a method name followed by that token, which creates a Closure referencing the function or method
D.Named arguments — a multi-line string syntax opened with three less-than signs and a single-quoted identifier whose body is treated literally with no variable parsing
A.the PHP 8.1 form using three dots in parentheses, such as a method name followed by that token, which creates a Closure referencing the function or method
B.a multi-line string syntax opened with three less-than signs and an identifier whose body still parses embedded variables like a double-quoted string
C.a multi-line string syntax opened with three less-than signs and a single-quoted identifier whose body is treated literally with no variable parsing
D.a single-expression closure written with the fn keyword that automatically captures variables from the enclosing scope by value
17. Which term means: "a single-expression closure written with the fn keyword that automatically captures variables from the enclosing scope by value"?
A.Arrow function — a single-expression closure written with the fn keyword that automatically captures variables from the enclosing scope by value
B.Arrow function — a parameter prefixed with three dots that collects any number of trailing arguments into a single array inside the function
C.Arrow function — passing values to a function by the parameter's name rather than its position, letting callers skip optional defaults and reorder freely
D.Arrow function — a multi-line string syntax opened with three less-than signs and an identifier whose body still parses embedded variables like a double-quoted string
A.passing values to a function by the parameter's name rather than its position, letting callers skip optional defaults and reorder freely
B.a multi-line string syntax opened with three less-than signs and an identifier whose body still parses embedded variables like a double-quoted string
C.the parsing of variable references embedded directly inside a double-quoted or heredoc string so their values are substituted into the output
D.the PHP 8.1 form using three dots in parentheses, such as a method name followed by that token, which creates a Closure referencing the function or method
20. Which term means: "the PHP 8.1 form using three dots in parentheses, such as a method name followed by that token, which creates a Closure referencing the function or method"?
A.First-class callable syntax — a multi-line string syntax opened with three less-than signs and an identifier whose body still parses embedded variables like a double-quoted string
B.First-class callable syntax — passing values to a function by the parameter's name rather than its position, letting callers skip optional defaults and reorder freely
C.First-class callable syntax — the PHP 8.1 form using three dots in parentheses, such as a method name followed by that token, which creates a Closure referencing the function or method
D.First-class callable syntax — the parsing of variable references embedded directly inside a double-quoted or heredoc string so their values are substituted into the output
Answers, AI explanations, and a scored voice mock interview
Sign up free to check your answers with explanations, ask the AI tutor anything on any question, and take one full AI mock interview — scored like a real panel.