Last Updated:

# Formatting string in PHP | Example

The PHP language provides many simple ways to convert strings into numbers. One condition is that the string must consist solely of numeric characters. If the string

consists of a set of letter characters, then it is only possible to get its length (length) or the character code in numerical format (intchar\int[] chars).

## Arithmetic operator "+" and transformation through "(int)"

This operator can translate from docu to number without using built-in functions. Let's break this down the string value:

## What happens if you apply all of these features to a character string?

Any operation performed on a character string will be zero. It does not matter whether the plus is placed before the line, whether the row is multiplied by a number, or whether an explicit transformation occurs using functions or (int).

The result will always be the same. And if you apply the var_dump() function, the result will be int(0), in some cases int(NaN) — Not a Number. This value is obtained by multiplying a number by a word or by arithmetic operations between character strings and numbers.

The most universal operator for converting a number to a string is "+", put before the line: +"44". This construct always translates a string into a number in all languages of the C family.