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
🌐
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.
🌐
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().
🌐
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.
🌐
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 - There is no difference between php sizeof() and count(). The sizeof() function is an alias of the count() function, which means that the function and usage of the sizeof() function are exactly the same as the count() function, and both can be ...
🌐
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 ...
🌐
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/>';
🌐
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().
🌐
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.
🌐
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.
🌐
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.
🌐
W3Schools
w3schools.com › php › func_array_sizeof.asp
PHP sizeof() Function
<?php $cars=array ( "Volvo"=>array ( "XC60", "XC90" ), "BMW"=>array ( "X3", "X5" ), "Toyota"=>array ( "Highlander" ) ); echo "Normal count: " . sizeof($cars)."<br>"; echo "Recursive count: " .
🌐
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.
🌐
TutorialsPoint
tutorialspoint.com › sizeof-function-in-php
PHP - Function sizeof()
December 23, 2019 - If the optional mode parameter is set to COUNT_RECURSIVE (or 1), sizeof() will recursively count the array. This is particularly useful for counting all the elements of a multidimensional array. The default value for mode is 0.
🌐
Tutorial Republic
tutorialrepublic.com › faq › how-to-count-all-elements-in-an-array-in-php.php
How to Count All Elements or Values in an Array in PHP
You can simply use the PHP count() or sizeof() function to get the number of elements or values in an array.
🌐
w3resource
w3resource.com › php › function-reference › sizeof.php
PHP : sizeof() function - w3resource
August 19, 2022 - PHP sizeof() function: The sizeof() function is used to count the elements of an array, or the properties of an object. This function is an alias of count().
🌐
DevOps
devopstrainer.in › home › difference between count or sizeof function in php
difference between count or sizeof function in PHP Archives - DevOps | SRE | DevSecOps
DevOps | SRE | DevSecOps · The accumulation objects in PHP are characterized by a length parameter to indicate the number of elements contained within it. It is necessary to estimate the length of an array…