length ... (string function)

Prev Next

Function Names

length

Description

This function returns the number of characters in the string. New line symbols count as 1 character. If the value provided is not a string, then it will be converted to a string first.
Attention: For numerals and dates with available string context, the string will be used.

A simpler approach is to use {} behind the string, referred as length of strings. This simplified appraoch runs faster, but assumes a string value to be provided all times.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1

Parameters

No.TypeDescription
1
input
valid types input string or value

Attention: If 1st parameter is a parameter set, please refer to length [parameter set function] instead. Values of types other than string will be converted to strings first.

Return value

TypeDescription
numeral Length

Number of characters

Examples

      echo( length( 007.0 ) );    // 5 characters (string context preserved)
      echo( length( 007.0 + 0 ) );    // 1 character (7) after a calculation
      echo( length( 1=1 ) );      // 4 characters (true)
      echo( length( Hello ) );    // 5 chracters
      echo( length( date(today)) );   // 10 characters: YYYY-MM-DD

Output

5
1
4
5
10
Try it yourself: Open LIB_Function_length.b4p in B4P_Examples.zip. Decompress before use.

See also

length [parameter set function]
width
length of strings