Why is my variable showing as undefined in php?

This error occurs when a variable is used without being previously defined. For instance, if you have a line like
echo $undefinedVar;
without initializing `$undefinedVar`.

Solution: Ensure to define your variable.

Example:

$undefinedVar = "Hello World";
followed by
echo $undefinedVar;
.

Beginner's Guide to PHP