phpstring

PHP difference between using a string cast versus using the strval() function


What is the difference between doing a (string) cast and strval() in PHP? Which should I use?

  1. (string)$value
  2. strval($value)

Solution

  • A value can be converted to a string using the (string) cast or the strval() function.

    ― https://www.php.net/manual/en/language.types.string.php#language.types.string.casting

    Looks the same to me.