gpt4 book ai didi

php - assert() 需要 1 个参数,给定 2 个

转载 作者:行者123 更新时间:2023-12-02 07:01:53 24 4
gpt4 key购买 nike

我按照 PHP 教程网站上的说明将两个参数传递给 assert 函数,但出现错误。这是我的做法:

assert('2 < 1', 'Two is less than one');

为什么失败了?

最佳答案

如果您使用的不是 php 5.4.8,您仍然可以通过在第一个断言参数中添加注释来获得有意义的消息:

$x = 1; $y = 2;
assert('$x > $y /*x should be greater than y*/');

这给出了输出:

Warning: assert(): Assertion "$x > $y /*x should be greater than y*/" failed in ...

关于php - assert() 需要 1 个参数,给定 2 个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19466412/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com