php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80936 php.exe -f test.php doesn't work
Submitted: 2021-04-05 08:33 UTC Modified: 2021-06-16 08:28 UTC
From: samsanchez at qq dot com Assigned: cmb (profile)
Status: Not a bug Package: Scripting Engine problem
PHP Version: * OS: Windows 10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: samsanchez at qq dot com
New email:
PHP Version: OS:

 

 [2021-04-05 08:33 UTC] samsanchez at qq dot com
Description:
------------
E:\Develop\php8>php -f test.php
<?php

echo 'hello php8';

Test script:
---------------
<?php

echo 'hello php8';

Expected result:
----------------
hello php8

Actual result:
--------------
<?php

echo 'hello php8';

Patches

rename_this_file_extension.txt (last revision 2021-04-06 14:31 UTC by samsanchez at qq dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-04-05 08:39 UTC] samsanchez at qq dot com
-Package: Compile Failure +Package: JIT
 [2021-04-05 08:39 UTC] samsanchez at qq dot com
change the package to JIT
 [2021-04-05 08:51 UTC] samsanchez at qq dot com
I find the problem is because the encode of test.php is UTF-8 With BOM!
changing the encode to UTF-8 without BOM make it work as expect.

however i think the php cli should raise me an error instead of output the whole source to me.
 [2021-04-05 15:29 UTC] cmb@php.net
I cannot reproduce, neither with JIT enabled nor disabled.
 [2021-04-06 14:31 UTC] samsanchez at qq dot com
The following patch has been added/updated:

Patch Name: rename_this_file_extension.txt
Revision:   1617719472
URL:        https://bugs.php.net/patch-display.php?bug=80936&patch=rename_this_file_extension.txt&revision=1617719472
 [2021-04-06 14:38 UTC] samsanchez at qq dot com
I attach a file with unicode bom. to reproduce this bug:

1) download the patch file 'rename_this_file_extension.txt'
2) open it by any kindof txt editor. add <?php to the 1st line
3) rename it to test.php
4) command line to exec: php.exe -f tes.php
5) output here it's
<?php

echo 'hello php8';

=====================
what i expect to get are
1) fatal error exception raise
2) or show me 'hello php8'
 [2021-04-07 13:21 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Package: JIT +Package: Scripting Engine problem -PHP Version: 8.0.3 +PHP Version: * -Assigned To: +Assigned To: cmb
 [2021-04-07 13:21 UTC] cmb@php.net
Ah, this is about UTF-16LE, not UTF-8.  I can confirm the reported
behavior, but this is not a bug; at least, you need to enable
zend.multibyte[1] for non ASCII compatible encodings; otherwise
the PHP engine doesn't recognize the <?php.  See also
<https://www.php.net/manual/en/migration71.windows-support.php>.

[1] <https://www.php.net/manual/en/ini.core.php#ini.zend.multibyte>
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 16:01:37 2025 UTC