| Newsgroups |
php.bugs |
| Message-ID |
<[email protected]> |
Edit report at https://bugs.php.net/bug.php?id=74339&edit=1
ID: 74339
Comment by: [email protected]
Reported by: spam2 at rhsoft dot net
Summary: BOGUS: Fatal error: strict_types declaration must be
the very first statement
Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: Linux
PHP Version: 7.1.3
Block user comment: N
Private report: N
New Comment:
Shebangs are explicitly ignored. Everything else that appears outside PHP tags is considered to be script output. This is the way that PHP has always worked.
To make your code work, do this:
<?php declare(strict_types=1); ?>
<html>
<head><title>Test</title></head>
<body>
<?php
// code here
?>
</body>
</html>
Previous Comments:
------------------------------------------------------------------------
[2017-03-30 11:57:17] [email protected]
This is defined behavior and is not a scripting engine problem
------------------------------------------------------------------------
[2017-03-30 11:47:56] spam2 at rhsoft dot net
Description:
------------
for cli scripts it's no problem to start with a #!/usr/bin/php shebang followed by <?php declare(strict_types=1); as first line, in case of mod_php the sample below throws "PHP Fatal error: strict_types declaration must be the very first statement in the script"
*it is* because PHP has no business to claim anything outside <?php ?> as part of "the script"
Test script:
---------------
<html>
<head><title>Test</title></head>
<body>
<?php declare(strict_types=1);
?>
</body>
</html>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74339&edit=1