Fatal error: Uncaught ArgumentCountError: Too few arguments to function

后端 未结 4 716
情话喂你
情话喂你 2020-12-09 23:10

I know there was a some questions related to this, but there are in c++ or other languages. I get this error and I\'m not sure what is wrong with my function.

My er

相关标签:
4条回答
  • 2020-12-09 23:44

    I experienced this same error after my hosting company updated our PHP version from 7.0.x to 7.1.x. They assumed that since it was a minor update, it should be compatible with previous versions. They were wrong: here's a list of the incompatibilities from the migration page.

    In this particular case code that would previously throw a warning about the lack of parameters for a function call is now throwing the fatal error in the OP's question.

    The solution is obviously to provide the appropriate parameters as the other answers have indicated.

    0 讨论(0)
  • 2020-12-09 23:51

    For anyone who encountered this error or something similar, the answer below works! I encountered this error when trying to get an older version of WordPress WooCommerce to run on PHP 7.2. Lol, I know. The WooCommerce Product Edit Screen was blank with the error below (which broke the product tabs)

    Fatal error: Uncaught ArgumentCountError: Too few arguments to function product_custom_tab::product_tab_options(), 0 passed in wp-includes/class-wp-hook.php on line 286 and exactly 1 expected in /wp-content/plugins/woo-product-tab/includes/product_custom_tab.php:64 Stack trace: #0 wp-includes/class-wp-hook.php(286):
    

    When going to line 64 of product_custom_tab.php. I changed

    public function product_tab_options($product_type)
    

    to

    public function product_tab_options($product_type = null)
    

    And it worked! Thanks to the contributors below! You really made my day. Thanks for being here. Thank you!

    Bytw: I tried to post this as a comment, but it wouldn't let me, so I posted this as an answer instead.

    0 讨论(0)
  • 2020-12-10 00:01

    Your method needs 5 arguments, you only pass 2: User->register('ds', 'dsssssss')

    Edit this line in Register.php:

    $user->register($username, $password)
    

    to

    $user->register($name, $surname, $username, $password, $email)
    

    Additionally you have this line twice $stmt->bindParam(":password", $password);

    0 讨论(0)
  • 2020-12-10 00:04

    In php 7 instead of:

        public function register($name, $surname, $username, $password, $email)
    {
    ...
    

    use:

    public function register($name = null, $surname = null, $username = null, $password = null, $email = null)
    {
    ...
    
    0 讨论(0)
提交回复
热议问题