从PHP 7.0切换到7.2后的未定义常量

my website hoster will soon switch all accounts from PHP 7.0 to PHP 7.2. So I installed a clone of my current WordPress installation in order to test it with PHP 7.2. When I have PHP 7.0 activated then everything works fine. But when I'm switching to PHP 7.2 I'm getting a weird error message from one of the plugins.

Warning: Use of undefined constant TABBER_TABS_DIR - assumed 'TABBER_TABS_DIR' (this will throw an Error in a future version of PHP) in /home/xeccbike/public_html/testing/wp-content/plugins/tabber-tabs-widget/tabber-tabs.php on line 31

30: / Set constant path to the plugin directory.
31: define( TABBER_TABS_DIR, plugins_url('tabber-tabs-widget/'));
32: 
33: // Load Language
34: load_plugin_textdomain('tabber-tabs-widget', false, TABBER_TABS_DIR . 'language');

Does anyone have an idea what that could be? Any hints are appreciated. Thanks

AJ

I had that too. I just put the constant in single quotes as suggested by the warning message (in your case that would be define( 'TABBER_TABS_DIR', plugins_url('tabber-tabs-widget/')); on line 31), which solved it.

Let’s look at this code snippet:

$string = test;

if ($string == 'test') {

    echo "This is test string";

}

Obviously you can see unquoted string test here. In PHP 7.1 output of the script would be:

Notice: Use of undefined constant test - assumed 'test' in ...
This is test string

but in PHP 7.2 the output would be:

Warning: Use of undefined constant test - assumed 'test' (this will throw an Error in a future version of PHP) in ...
This is test string

As you see it’s not a big change (Notice was changed into Warning), however in PHP 8 it will probably cause an error.

The main cause of this change is not stopping just support for unquoted string but to avoid serious problems when you typo some PHP keywords.

I suggest I suggest reading this article. Maybe useful