Konstanta ajaib seperti __DIR__ sangat penting saat menyertakan file (include/require) dengan path absolut yang aman.
PHP Magic Constants
Contoh Kode PHP Magic Constants:
<!DOCTYPE html>
<html>
<body style="font-family: monospace; padding: 20px; background: #1e293b; color: #38bdf8;">
<p><?php<br>
echo "Folder saat ini: " . __DIR__ . "<br>";<br>
echo "File saat ini: " . __FILE__ . "<br>";<br>
echo "Baris kode saat ini: " . __LINE__;<br>
?></p>
</body>
</html>
Uji kode PHP dan amati simulasi output server pada panel pratinjau di atas.