Unquoted text as a variable value in PHP
<?php
$animal = CAT; // outputs Notice: Use of undefined constant cat - assumed 'cat'
echo $animal; // ouputs CAT
define('CAT', '4 legs');
$animal = CAT;
echo $animal; // outputs 4 legs
/* conclusion: undefined constant name and unquoted string value will be converted into string automatically */
?>
$animal = CAT; // outputs Notice: Use of undefined constant cat - assumed 'cat'
echo $animal; // ouputs CAT
define('CAT', '4 legs');
$animal = CAT;
echo $animal; // outputs 4 legs
/* conclusion: undefined constant name and unquoted string value will be converted into string automatically */
?>
Comments
Post a Comment