Tsallaka zuwa abun ciki
Justice Tech School

Constants and Magic Constants

define() and const create constants. __LINE__, __FILE__, __DIR__ and __FUNCTION__ are magic constants.

Example
const PI = 3.14;
define("APP", "demo");
echo PI, " ", APP, " ", __LINE__, "\n";
function f() { return __FUNCTION__; }
echo f();

Result

3.14 demo 4
f

Exercise

Define a constant.

("A", 1);

Quiz Test

Do constants use $?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.