1. Home
  2. Computer Science MCQs
  3. PHP
  4. Which PHP function returns the number of bytes in a string?

Added 2 Nov 2026

Which PHP function returns the number of bytes in a string?

  1. sizeof()
  2. length()
  3. count()
  4. strlen() Correct answer

Correct answer

D. strlen()

18 views

MCQSEXAM

Explanation

strlen() counts bytes, so for multibyte UTF-8 text such as Urdu use mb_strlen(). count() and its alias sizeof() count array elements, and length() does not exist in PHP.

Reference

Asked in: NTS, PPSC, PHP Developer Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is D? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More PHP MCQs

Practise all PHP MCQs

Similar MCQs