I would use count() if they are the same, as in my experience it is more common, and therefore will cause less developers reading your code to say "sizeof(), what is that?" and having to consult the documentation.

I think it means sizeof() does not work like it does in C (calculating the size of a datatype). It probably made this mention explicitly because PHP is written in C, and provides a lot of identically named wrappers for C functions (strlen(), printf(), etc)

Answer from alex on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › php › what-is-the-difference-between-count-and-sizeof-functions-in-php
What is the difference between count() and sizeof() functions in PHP ? - GeeksforGeeks
July 23, 2025 - It can be used for both uni-dimensional as well as multi-dimensional arrays. The sizeof() method takes a longer execution time. Also, the sizeof() method is an alias of the count() method. ... Example: This example describes the basic usage of the sizeof() method in PHP.
🌐
PHP
php.net › manual › en › function.sizeof.php
PHP: sizeof - Manual
I would recommend not using sizeof(). Many programmers expect sizeof() to return the amount of memory allocated. Instead sizeof() -as described above- is an alias for count().
🌐
Medium
medium.com › @jochelle.mendonca › exploring-php-count-vs-sizeof-unveiling-the-differences-a87ca9d57660
xploring PHP: Count vs. Sizeof — Unveiling the Differences | Medium
January 3, 2024 - At a glance, both count() and sizeof() may seem like twins separated at birth, but they are, in fact, aliases in PHP. That's right – they are essentially identical in functionality.
🌐
Reintech
reintech.io › blog › comprehensive-guide-php-count-sizeof-functions
A Comprehensive Guide to PHP's `count()` and `sizeof()` Functions
Here's a critical fact that often surprises developers: sizeof() is not a separate function—it's an alias of count(). Both function names point to the exact same internal implementation. This means there's zero performance difference between them, and choosing one over the other is purely ...
🌐
php.cn
m.php.cn › home › backend development › php problem › what is the difference between php sizeof and count
What is the difference between php sizeof and count-PHP Problem-php.cn
September 23, 2021 - PHP provides us with two functions to calculate the length of an array, namely the count() and sizeof() functions. But in fact, there is no difference between the count() and sizeof() functions. The sizeof() function is an alias of the count() ...
🌐
DevOps
devopstrainer.in › home › what is the difference between count or sizeof function in php? explain with example
What is the difference between count or sizeof function in PHP? explain with example - DevOps | SRE | DevSecOps
November 1, 2022 - It is necessary to estimate the length of an array in order to perform array manipulations and modifications. sizeof() function: The sizeof() function is used to calculate all the elements present in an array or any other countable object.
Find elsewhere
🌐
PHP MySQL
maheshkanna.wordpress.com › 2013 › 02 › 14 › what-is-the-difference-between-count-and-sizeof-in-php
What is the difference between count() and sizeof() in PHP? | PHP MySQL
February 14, 2013 - The default value for mode is 0. – sizeof() function is an alias of count() function – Example below: /* Simple Example */ $a = array(1,2,3,4); echo ” Example #1″; echo ” Count of A array is :”.count($a); echo ” Size of A array ...
🌐
Paulsprogrammingnotes
paulsprogrammingnotes.com › 2012 › 10 › sizeof-vs-count-in-php.html
Sizeof() vs Count() in PHP · Paul's Programming Notes
October 22, 2012 - 22 Oct 2012 http://php.net/manual/en/function.sizeof.php They're the same. According to the link above: the sizeof function is an alias of: count().
🌐
Blogger
evergreenphp.blogspot.com › 2008 › 09 › difference-between-sizeof-and-count-in.html
Difference between sizeof() and count() in php
September 1, 2008 - If no argument supplied into sizeof() ,it's shown in Warning.. If no argument supplied into count() ,it's shown in Fatel error..
🌐
Svachon
svachon.com › blog › benchmark-php-strlen-vs-count
Benchmark: PHP strlen vs. count (and sizeof) • Steven Vachon's Blog
March 25, 2012 - For the sake of search engines, I included sizeof() in the title. There was no need to include it in the benchmark as it’s the same as count() and runs at the same speed. ... <?php $test_array = array(0,1,2,3,4,5); $test_string = '/test/'; function getmicrotime() { list($usec, $sec) = explode(' ',microtime()); return ((float)$usec + (float)$sec); } $time_start = getmicrotime(); for ($i=0; $i<1000000; $i++) { count($test_array); } echo 'count() :: '.number_format(getmicrotime()-$time_start,3).' seconds<br/>'; $time_start = getmicrotime(); for ($i=0; $i<1000000; $i++) { strlen($test_string); } echo 'strlen() :: '.number_format(getmicrotime()-$time_start,3).' seconds<br/>';
🌐
DevOps
devopstrainer.in › home › difference between count or sizeof function in php
difference between count or sizeof function in PHP Archives - DevOps | SRE | DevSecOps
The accumulation objects in PHP are characterized by a length parameter to indicate the number of elements contained within it.
🌐
Medium
medium.com › @teamcode20233 › getting-the-length-of-an-array-in-php-3f10f7dd3719
Getting the Length of an Array in PHP | by Teamcode | Medium
May 30, 2023 - The count() function, which is the most commonly used and returns the number of elements in an array. The sizeof() function, which is an alias for count() and works exactly the same way.
🌐
FlatCoding
flatcoding.com › home › php sizeof: how to count elements in arrays with examples
PHP sizeof: How to Count Elements in Arrays with Examples - FlatCoding
August 31, 2025 - The sizeof is an alias of count. Both behave the same way in normal use. Developers often choose one based on style or readability. Here is a table that shows you the key differences: You can use either function.
🌐
Wordpress
vijaymrami.wordpress.com › 2016 › 02 › 03 › count-array-key-values-with-array_count_values-count-and-sizeof-php-functions
Count array key values with array_count_values, count and sizeof PHP functions – PHP Website Development
February 5, 2016 - sizeof According to the php.net, sizeof() is an alias of count() It count all the elements in an array. One more important thing is: If your array is “huge” It is reccomended to set a v…
🌐
Carmatec
carmatec.com › home › how to get the length of an array in php: complete guide
How to Get the Length of an Array in PHP: Complete Guide
September 28, 2024 - ... C The length of the array is: 5 In this example, the count() function returns the total number of elements in the array, which is 5. The sizeof() function is an alias of count() in PHP.
🌐
Scaler
scaler.com › home › topics › how to find the length of an array in php?
How to Find the Length of an Array in PHP? - Scaler Topics
April 12, 2024 - Consistency and Readability: The primary reason to favor count() over sizeof() is consistency. Most PHP developers are familiar with the count() function, making your code more readable and easier to understand for others.
🌐
DEV Community
dev.to › techyhunger › calculate-php-array-length-2elb
Array Length PHP: Calculate PHP Array Length - DEV Community
August 21, 2019 - It is advised to always use count() instead of sizeof(). Because there is no guarantee for the alias function if they will exist or not in a future upgrade.
🌐
Medium
sergheipogor.medium.com › php-count-catastrophes-when-not-to-use-it-90f732e897b0
PHP count() Catastrophes - When NOT to Use It | by Serghei Pogor | Medium
May 10, 2024 - So, remember, when dealing with massive arrays in PHP, opt for sizeof() over count() to keep your code running at full speed ahead!