Possible Duplicate:
Converting an integer to a string in PHP
$variable = '2011'
$temp = tostring($variable);
How can I convert integer to string? Is any tostring()
method available?
Possible Duplicate:
Converting an integer to a string in PHP
$variable = '2011'
$temp = tostring($variable);
How can I convert integer to string? Is any tostring()
method available?
PHP is dynamically typed, so your var is both a string and an integer
However, you can do type casting like so
$intval = (int) $string;
$string = (string) $intval;
or simply by saying
$string = "$intval";
But it shouldn't matter, because the string you make will still work as an integer
Cast it to a string:
$temp=(string)$variable;
...but why do you need it? Much of PHP doesn't care about types and implicitly converts it whenever needed.
As I've read your comments on recent answers, I can add the following:
$variable = '2011';
is already a string, but you need to concat it like this:
$start_date = $get_year . $get_month . $date_01;
Otherwise php will treat the "Stringed" digits as numbers, and just add up the values using the +
-operator. Hope this solves your problem!