count text length php

PHP
<?php
$str = 'Hello World!';
echo strlen($str); // 12
?>$name = "Perú"; // With accent mark
echo strlen($name); // Display 5, because "ú" require 2 bytes.

$name = "Peru"; // Without accent mark
echo strlen($name); // Display 4
Source

Also in PHP: