Home>

I am studying PHP on the web. Although it is displayed, I want to erase it because I'm worried about Warning. What should I do? It appears if constant Tom is not defined,
I don't know how to do this.
I use winndows10, Notepad ++, Xammp.
Please.

Warning: Use of undefined constant Tom-assumed 'Tom' (this will throw an Error in a future version of PHP) in C: \ xampp \ htdocs \ php_sample \ php_lessons \ index_12a.php on line 26
hi! Tom
Warning: Use of undefined constant Bob-assumed 'Bob' (this will throw an Error in a future version of PHP) in C: \ xampp \ htdocs \ php_sample \ php_lessons \ index_12a.php on line 27
hi! Bob
<? php
// function
function sayHi ($name) {
    echo "hi!". $name;
}
sayHi (Tom);
sayHi (Bob);
?>
php
  • Answer # 1

    In addition to variables starting with "$", PHP has constants with no prefix

    sayHi (Tom);
    sayHi (Bob);

    The PHP side interprets it maximally and favorably
    Tom works hard with the constant "Tom" and Bob with the constant "Bob".
    Is that really OK? That is the intention of warning

    define ('Tom', 'Tom');
    function sayHi ($name) {
        echo "hi!". $name;
    }
    sayHi (Tom);
    sayHi (Bob);


    This will tell you that Tom's warning disappears

  • Answer # 2

    sayHi ('Tom'); sayHi ('Bob');

  • Answer # 3

    It seems to be treated as a constant rather than a string.
    If it passes as a character as follows, it is a big job.

    sayHi ('Tom');
    sayHi ('Bob');

  • Answer # 4

    This is somehow out ... aside
    If you can see the PHP string