What could be the reason for always getting a 0 output when trying to count characters in a PHP script?

The issue of always getting a 0 output when trying to count characters in a PHP script could be due to not properly initializing the variable that stores the count of characters. To solve this issue, make sure to initialize the variable before counting the characters. This can be done by setting the initial value of the variable to 0 before iterating through the string to count the characters.

<?php
// Initialize the variable to store the count of characters
$count = 0;

// Input string to count characters
$inputString = "Hello, World!";

// Iterate through the string to count characters
for ($i = 0; $i < strlen($inputString); $i++) {
    $count++;
}

// Output the count of characters
echo "Number of characters: " . $count;
?>