Title: Access PHP function from another snippet
Last modified: September 25, 2019

---

# Access PHP function from another snippet

 *  [ocglimited](https://wordpress.org/support/users/ocglimited/)
 * (@ocglimited)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/access-php-function-from-another-snippet/)
 * 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)

 *  [Temyk](https://wordpress.org/support/users/webtemyk/)
 * (@webtemyk)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/access-php-function-from-another-snippet/#post-11970005)
 * 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.

 * ![](https://ps.w.org/insert-php/assets/icon-256x256.gif?rev=3523853)
 * [Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts](https://wordpress.org/plugins/insert-php/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-php/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-php/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-php/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-php/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-php/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Temyk](https://wordpress.org/support/users/webtemyk/)
 * Last activity: [6 years, 8 months ago](https://wordpress.org/support/topic/access-php-function-from-another-snippet/#post-11970005)
 * Status: not resolved