dongpo1599 2017-11-13 09:20
浏览 134
已采纳

PHP ArgumentCountError服务器是否特定?

I am facing very weird problem since last two days, I have two different servers one is windows(php v5.3) and second is linux(php v7.1 ngnix). I have a project(written by someone) which is already running on windows server, now I have to move this project on linux server (with no code change). My issue, There is a login function -

Function userAuthentication($username,$password,$locationId,$url,$source)
{
....
}

And It is calling as (On windows server)

userAuthentication($username, $password,'',$url) ;

I know parameters are mismatched in this case but as I tested, this code is actually giving me result and working fine on windows but that same code is giving me obvious error on Linux server-

ArgumentCountError: Too few arguments to function Authentication::userAuthentication(), 4 passed in

It can be resolve by changing that code but I don't want (can to be many function with same error). I already googled but not found anything. I am very curious to know Why this is not happening on windows. Is that ArgumentCountError server specific or windows server not taking it as critical as linux, or php version issue or any other config.? what I suppose to fix to resolve this issue.?

Anyone have any idea about that please help me out, Thanks

  • 写回答

3条回答 默认 最新

  • dongliu0823 2017-11-13 09:30
    关注

    The difference isn't in the Environment (windows vs. linux) rather the PHP version.

    As you can see in the migration from PHP 7.0 to 7.1 (link: http://php.net/manual/en/migration71.incompatible.php)

    Throw on passing too few function arguments

    Previously, a warning would be emitted for invoking user-defined functions with too few arguments. Now, this warning has been promoted to an Error exception. This change only applies to user-defined functions, not internal functions. For example:

    <?php
    function test($param){}
    test();
    

    The above example will output something similar to:

    Fatal error: Uncaught ArgumentCountError: Too few arguments to function test(), 0 passed in %s on line %d and exactly 1 expected in %s:%d

    How to solve it?

    You'll have to define all the parameters in the function. It might be "uncomfortable" but it's a better practice as a developer. Don't be lazy regarding this issue.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line