Skip to content

PHP Warning: Constant already defined when processing multiple sources with __halt_compiler() #18850

Open
@ProgerXP

Description

@ProgerXP

Description

Whenever PHP processes more then one __halt_compiler() statement in one session, it emits this cryptic warning:

PHP Warning:  Constant  already defined in ...

Note the empty constant name.

There are several ways to trigger this. Here's one:

# echo '<?php __halt_compiler();' >inc.php
# php -a
php > include('inc.php');
php > include('inc.php');
PHP Warning:  Constant  already defined in /tmp/inc.php on line 1

Here's another:

# php -r "eval('?><?php __halt_compiler();'); eval('?><?php __halt_compiler();');"

PHP Version

PHP 8.4.5 (cli) (built: Mar 12 2025 16:58:15) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.5, Copyright (c) Zend Technologies

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions