'wordpress PHP error occuring how can i solve?

Fatal error: Uncaught Error: Call to undefined function split() in /home/yourdemo/domains/yourdemosite.live/public_html/wp-content/plugins/wordpress-hit-counter/image.php:66

Stack trace:

  • #0 /home/yourdemo/domains/yourdemosite.live/public_html/wp-includes/class-wp-hook.php(307): HitCounter->counter(Object(WP))
  • #1 /home/yourdemo/domains/yourdemosite.live/public_html/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
  • #2 /home/yourdemo/domains/yourdemosite.live/public_html/wp-includes/plugin.php(522): WP_Hook->do_action(Array)
  • #3 /home/yourdemo/domains/yourdemosite.live/public_html/wp-includes/class-wp.php(771): do_action_ref_array('wp', Array)
  • #4 /home/yourdemo/domains/yourdemosite.live/public_html/wp-includes/functions.php(1310): WP->main('')
  • #5 /home/yourdemo/domains/yourdemosite.live/public_html/wp-blog-header.php(16): wp()
  • #6 /home/yourdemo/domains/yourdemosite.live/public_html/index.php(17): require('/home/yourdemo/...')
  • #7 {main} thrown in /home/yourdemo/domains/yourdemosite.live/public_html/wp-content/plugins/wordpress-hit-counter/image.php on line 66


Solution 1:[1]

This is the PHP version issue:

Your site is trying to use a function, split(), that was removed in PHP 7. I suspect the issue is that your theme is out of date. Every refernce to “ubergeist” I find is from 2011, so you may be using a very old theme that has not been updated. That’s a commercial theme, but is no longer available.

https://wordpress.org/support/topic/fatal-error-message-how-do-i-fix-this-2/

Your plugin wordpress-hit-counter use the function split() that was removed in PHP 7. So, you have to upgrade your plugin if possible your use another alternative instead of that.

Also, the bad and NOT RECOMMENDED way is to downgrade the PHP version to something before version 7.

Solution 2:[2]

you can use global variables to keep your data in them and call them between your functions.

check out this page: What is the pythonic way of saving data between function calls? maybe solve your problem if you want to use the class and attribute solution.

Solution 3:[3]

You should use a class when you want to store data.

An small example is given below, but please look online for tutorial and examples to fully understand the working of classes and OOP in python.

class Storedata:
    def __init__(self, x, y):
        self.arr = []
        self.max_arr_size = y
        self.add_data(x)
    def add_data(self, x):
        if len(self.arr) < self.max_arr_size:
            self.arr.append(x)
    def __call__(self):
        return sum(self.arr)/len(self.arr)

storedata = Storedata(3, 5)
print(storedata.arr)
>>> [3]
print( storedata() )
>>> 3.0
storedata.add_data(5)
print( storedata() )
>>> 4.0

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Draxsis
Solution 3