总有人间一两风,填我十万八千梦

PHP ArgumentCountError 用法 手册 | 示例代码

PHP开发手册 归档 242℃ 0评论

ArgumentCountError

(PHP 7 >= PHP 7.1.0, PHP 8)

简介

ArgumentCountError 当传递给用户定义的函数或方法的参数太少时被抛出。

类摘要

ArgumentCountError extends TypeError {
/* 继承的属性 */
protected string $message;
protected int $code;
protected string $file;
protected int $line;
/* 继承的方法 */
final public Error::getMessage(): string
final public Error::getCode(): mixed
final public Error::getFile(): string
final public Error::getLine(): int
final public Error::getTrace(): array
final public Error::getTraceAsString(): string
public Error::__toString(): string
final private Error::__clone(): void

}

用户贡献的笔记

T7To7

Note if an invalid number of arguments are passed to a built-in function an ArgumentCountError exception will be thrown if and only if your code is in strict mode.

<?php
declare(strict_types = 1);

try {
    echo strlen('ahmed', 4);
} catch (
ArgumentCountError $e) {
    echo
$e->getMessage()';
}
?>

转载请注明:悠然品鉴 » PHP ArgumentCountError 用法 手册 | 示例代码

喜欢 (1)or分享 (0)
发表我的评论
取消评论

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址