php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #59060 compiling php file with shebang causes unexecutable php files
Submitted: 2010-02-03 10:30 UTC Modified: 2010-02-03 12:12 UTC
From: bugs at bilke dot org Assigned:
Status: Not a bug Package: bcompiler (PECL)
PHP Version: 5.2.10 OS:
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: bugs at bilke dot org
New email:
PHP Version: OS:

 

 [2010-02-03 10:30 UTC] bugs at bilke dot org
Description:
------------
Compiling a php file with a shebang causes no executable php file.

Reproduce code:
---------------
compile code:

$f = fopen('target.php', "w");
bcompiler_write_header($f);
bcompiler_write_file($f, 'source.php');
bcompiler_write_footer($f);
fclose($f);

file:
#!/usr/bin/php
<?php
echo 'Hello World' . "\n";
?>

Expected result:
----------------
$ ./target.php 
Hello World

Actual result:
--------------
$ ./target.php 
./target.php: Exec format error. Binary file not executable.
Exit 1

$ php target.php 
#!/usr/bin/php
Hello World

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-03 12:12 UTC] val@php.net
target.php isn't supposed to be an executable file. Bytecode should be loaded in PHP (currently you can use include/require keywords to load bytecodes just as a normal PHP source file).

Alternatively, you might consider looking at http://www.php.net/manual/en/function.bcompiler-write-exe-footer.php and examples/embed directory on SVN to learn how to build a binary [executable] file, but it's tricky and require some familiarity with PHP sources.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 07:01:28 2024 UTC