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

What's the difference between isset() and array_key_exists() ?

Câu trả lời

Here is the difference between isset() and array_key_exists() in PHP:

isset()

  • isset() checks if a variable is set and is not NULL.
  • For arrays, isset() checks if the specified key exists and has a non-NULL value.
  • If the key exists but its value is NULL, isset() will return false.
  • isset() can check multiple variables/array keys at once, returning true only if all of them are set.

array_key_exists()

  • array_key_exists() checks if the specified key exists in the given array, regardless of its value.
  • It returns true if the key exists, even if its value is NULL.
  • array_key_exists() can only check one array key at a time.

In summary:

...

junior

junior

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

junior

What are the different scopes of variables?

senior

Explain the Exception Hierarchy introduced in PHP7

junior

What are PSRs? Choose 1 and briefly describe it

Bình luận

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

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