Skip to content

Error level changed in preg_match and preg_match_all functions #1595

Closed
@NVoronina

Description

@NVoronina

Error changed if you use not a string as second argument in preg_match function from E_WARNING before 8.0 to TypeError in 8+ versions.
Code example:
<?php $var = preg_match('#[0-9]#', ['test']); var_dump($var);

Result 7.4:
Warning: preg_match() expects parameter 2 to be string, array given in /home/user/scripts/code.php on line 3
bool(false)

Result 8.0:
Fatal error: Uncaught TypeError: preg_match(): Argument #2 ($subject) must be of type string, array given in /home/user/scripts/code.php:3

PS preg_match_all the same behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions