Answers for "convert into string in php"

PHP
14

integer to string php

return strval($integer);
Posted by: Guest on April-06-2020
5

php to string

$number = 10;
// To convert this number to a string:
$numberString = (string)$number;
Posted by: Guest on October-30-2020
6

convert int to string php

$var = 5;

// Inline variable parsing
echo "I'd like {$var} waffles"; // = "I'd like 5 waffles

// String concatenation 
echo "I'd like ".$var." waffles"; // I'd like 5 waffles

// Explicit cast 
$items = (string)$var; // $items === "5";

// Function call
$items = strval($var); // $items === "5";
Posted by: Guest on November-20-2019
1

php convert to string

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

// Prints 'StrValTest'
echo strval(new StrValTest);
?>
Posted by: Guest on April-02-2020

Code answers related to "convert into string in php"

Browse Popular Code Answers by Language