Which data type will the $a variable have at the end of the following script?

<?php
$a = “1”;
echo $a;
?>

A. (int) 1
B. (string) “1”
C. (bool) True
D. (float) 1.0
E. (float) 1

Answer B is correct.

When a numeric string is assigned to a variable, it remains
a string, and it is not converted until needed because of an operation that
requires so.

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.