Câu hỏi phỏng vấn PHP
Câu hỏi

What is the return type of a function that doesn't return anything?

Câu trả lời

In PHP, a function that doesn't explicitly return anything using the return statement will implicitly return null. This means that the return type of such a function is mixed, which can be either a specific data type or null.

Here's an example:

php Copy
function myFunction() {
    echo "Hello, world!";
}

$result = myFunction();
var_dump($result); // Output: NULL

In this case, the myFunction() doesn't have a return statement, so it implicitly returns null. When you assign the result of myFunction() to the $result variable and use var_dump() to inspect its v...

entry

entry

Gợi ý câu hỏi phỏng vấn

junior

What are the different scopes of variables?

junior

What is the difference between var_dump() and print_r() ?

junior

What is the difference between single-quoted and double-quoted strings in PHP?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào