使用未定义常量 __DIR__

Suj*_*oni 2 php

我收到以下错误:

注意:使用未定义常量__DIR__- 假定'__DIR__'在 /home/a2708294/public_html/firebase/index.php 第 58 行

线路:58

require_once __DIR__ . '/firebase.php';
require_once __DIR__ . '/push.php';
Run Code Online (Sandbox Code Playgroud)

Dan*_*das 7

魔法常量__DIR__是在 PHP 5.3.0 版本中添加的,您可以在这里查看: http: //php.net/manual/en/language.constants.predefine.php

您需要将 php 升级到较新的版本。无论如何,您需要升级,因为您的版本非常旧。

如果你无法升级 php,你可以将其用作dirname(__FILE__)hack,因为__FILE__PHP 4.0.2 版本中存在魔法常量

所以你的代码将如下所示:

require_once(dirname(__FILE__) . '/firebase.php');
require_once(dirname(__FILE__) . '/push.php');
Run Code Online (Sandbox Code Playgroud)