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

middle

Is there any reason to use strcmp() for strings comparison?

middle

What are some of the big changes PHP has gone through in the past few years?

middle

Differentiate between parameterised and non parameterised functions

Bình luận

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

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