最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Suppress errors when using global function

programmeradmin3浏览0评论

I'm using the NinjaForms plugin which defines a Ninja_Forms() global function.

Although I can call it without problem, I still get a warning/error

Undefined function 'Ninja_Forms'.

If this were a variable I'd use global foo to suppress that.

How do I do that for a global function - i.e. is there a global equivalent for functions?

I'm using the NinjaForms plugin which defines a Ninja_Forms() global function.

Although I can call it without problem, I still get a warning/error

Undefined function 'Ninja_Forms'.

If this were a variable I'd use global foo to suppress that.

How do I do that for a global function - i.e. is there a global equivalent for functions?

Share Improve this question edited Jan 27, 2020 at 7:04 lonix asked Jan 26, 2020 at 9:18 lonixlonix 3011 silver badge10 bronze badges 6
  • Global isn’t a magic way to suppress errors. You have a problem with your code that actually needs to be fixed. Where and how are you using the function? – Jacob Peattie Commented Jan 26, 2020 at 10:12
  • I'm using the function as advertised by its author. I want to know what is the "global" equivalent for functions, if at all. The downvote was unnecessary. – lonix Commented Jan 26, 2020 at 10:54
  • There isn’t one. The premise of your question is incorrect, which is why I’m saying that something else is wrong. And you didn’t answer my question: Where and how are you using the function? – Jacob Peattie Commented Jan 26, 2020 at 13:54
  • That is irrelevant to my question - which was whether there is a global equivalent for functions? If not, then that's the answer. I don't like globals, but sometimes it's necessary/convenient. NinjaForms is a very popular plugin, so I'm not doing anything wrong. Thanks for your help. – lonix Commented Jan 27, 2020 at 6:52
  • You are doing something wrong. If you weren’t there’d be no error. But you’re clearly not actually interested in figuring out what it is, having invented your own solution and refused to provide any information that could be used to help. For your own sake I hope that you’re less needlessly stubborn the next time you ask for help. – Jacob Peattie Commented Jan 27, 2020 at 6:58
 |  Show 1 more comment

1 Answer 1

Reset to default -1

According to comments above, there is no "global" equivalent for functions. So I'm just gonna live with the warning, since everything works.

发布评论

评论列表(0)

  1. 暂无评论