You can use the casting operators:
$myText = (string)$myVar;
There are more details for string casting and conversion in the Strings section of the PHP manual, including special handling for booleans and nulls.
Related Contents:
- How do I check if a string contains a specific word?
- startsWith() and endsWith() functions in PHP
- How to get the last char of a string in PHP?
- How to generate a random, unique, alphanumeric string?
- How to remove non-alphanumeric characters?
- Using str_replace so that it only acts on the first match?
- How can I remove three characters at the end of a string in PHP?
- Convert flat array to a delimited string to be saved in the database
- Truncate a string to first n characters of a string and add three dots if any characters are removed
- Insert string at specified position
- How to Convert Boolean to String
- PHP – concatenate or directly insert variables in string
- Curly braces in string in PHP
- PHP substring extraction. Get the string before the first ‘/’ or the whole string
- How to Truncate a string in PHP to the word closest to a certain number of characters?
- Best Practices: working with long, multiline strings in PHP?
- How to get everything after a certain character?
- How to get the first word of a sentence in PHP?
- Mixing a PHP variable with a string literal
- Replace last occurrence of a string in a string
- Add … if string is too long PHP [duplicate]
- Iterate over each line in a string in PHP
- Remove all non-numeric characters from a string; [^0-9] doesn’t match as expected
- php implode (101) with quotes
- PHP String to Float
- How to convert PascalCase to snake_case?
- What’s the most efficient test of whether a PHP string ends with another string?
- Remove Trailing Slash From String PHP
- How do you pull first 100 characters of a string in PHP
- PHP: convert spaces in string into %20?
- When to use strtr vs str_replace?
- How to cast array elements to strings in PHP?
- How to strip trailing zeros in PHP
- find if date is older than 30 days
- Is there any way to return HTML in a PHP function? (without building the return value as a string)
- How to include a PHP variable inside a MySQL statement
- Remove control characters from PHP string
- Get first 100 characters from string, respecting full words
- Find first character that is different between two strings
- How to compare 2 strings alphabetically in PHP?
- Splitting strings in PHP and get the last part [duplicate]
- Is a new line = \n OR \r\n?
- how to count new lines in a very big string?
- How to create a random string using PHP?
- Does PHP have a feature like Python’s template strings?
- PHP to write Tab Characters inside a file?
- How create an array from the output of an array printed with print_r?
- Obtain first line of a string in PHP
- PHP removing a character in a string
- How to get the position of a Regex match in a string? [duplicate]