• I have created a simple PHP function as a PHP snippet, available everywhere.

    I then created a universal snippet with JS code, available everywhere, and in the code (using PHP tags) I call my php function above.

    Trying to save the universal snippet causes an error that my PHP function can’t be found. I assume this relates to the order in which snippets are loaded? Is there a way for one snippet to reliably call global PHP functions from another snippet without having to worry about load order?

    Or…what else is wrong?

Viewing 1 replies (of 1 total)
  • Hello.

    The problem is not in the order of calling snippets. It’s because of the scope. Each snippet is called and processed separately from the other snippets, so they do not see each other.
    In the case of variables, you can do this:
    global $variable;
    But there is no way for functions. You can write a function to a file and include it where you want.

Viewing 1 replies (of 1 total)

The topic ‘Access PHP function from another snippet’ is closed to new replies.