Undefined constant error in php 7.2

后端 未结 3 1069
無奈伤痛
無奈伤痛 2020-12-14 03:07

I have theses errors in php v7.2 but don\'t see any E_WARNING when using php v7.1.

How can I resolve following errors?

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-14 03:33

    In addition, for those who are new to wordpress Plugin development and cant seem to figure out what it means to define "Constant" before its used...

    Here is an example of what will throw an error:

    add_action('wp_enqueue_scripts', myprefix_load_styles);
    

    Declaring a function directly like that in a hook is one way to generate an error like this. Instead:

    add_action('wp_enqueue_scripts', 'myprefix_load_styles');
    

    Note, the function name is now inside the quotes. And that should work, if thats your scenario.

提交回复
热议问题