Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Helper.php

function Helper::length

Returns the length of a string, using mb_strlen if it is available. The length is related to how many bytes the string will use.

2 calls to Helper::length()
ProgressBar::initPlaceholderFormatters in vendor/symfony/console/Helper/ProgressBar.php
Table::renderCell in vendor/symfony/console/Helper/Table.php
Renders table cell with padding.

File

vendor/symfony/console/Helper/Helper.php, line 59

Class

Helper
Helper is the base class for all helper classes.

Namespace

Symfony\Component\Console\Helper

Code

public static function length(?string $string) : int {
    $string ??= '';
    if (preg_match('//u', $string)) {
        return (new UnicodeString($string))->length();
    }
    if (false === ($encoding = mb_detect_encoding($string, null, true))) {
        return \strlen($string);
    }
    return mb_strlen($string, $encoding);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal