strval

Get string value of a variable

&reftitle.description; `string` `strval` `mixed` `value`

Get the string value of a variable. See the documentation on `string` for more information on converting to string.

This function performs no formatting on the returned value. If you are looking for a way to format a numeric value as a string, please see `sprintf` or `number_format`.

&reftitle.parameters;

`value`

- The variable that is being converted to a `string`.

  `value` may be any scalar type, `null`, or an `object` that implements the __toString() method. You cannot use `strval` on arrays or on objects that do not implement the __toString() method.

&reftitle.returnvalues;

The `string` value of `value`.

&reftitle.examples;

### `strval` example using PHP magic __toString() method.

    <?php
    class StrValTest
    {
        public function __toString()
        {
            return __CLASS__;
        }
    }

    // Prints 'StrValTest'
    echo strval(new StrValTest);
    ?>

&reftitle.seealso;

- `boolval`
- `floatval`
- `intval`
- `settype`
- `sprintf`
- `number_format`
- Type juggling
- __toString()