Get the path of the current script

echo __FILE__;

Get the directory of the current script

echo realpath(dirname(__FILE__));

Fix those pesky PDO SQLSTATE[HY000] [2002] No such file or directory errors

  • Try using 127.0.0.1 instead of localhost for DB host
  • Add a utf-8 charset

Do a 301 permanent redirect

header("Location: https://www.example.com", true, 301);