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 */
?>

Comments

Popular posts from this blog

Timus Problem 1086. Cryptography Accepted Solution in C