Re: PHP compiler

From: CountScubula (me_at_scantek.hotmail.com)
Date: 03/08/04


Date: Mon, 08 Mar 2004 20:34:13 GMT


"Nikola Skoric" <nick-news@net4u.hr> wrote in message
news:MPG.1ab64a8fe5f7ea1198971a@localhost...
> (snip)
> No. See, you didn't understand my question correctly. I don't actually
> need a PHP compiler, what I need is an *information* wether that
> compiler exists. And why's that? Becouse my team and I might be doing a
> PHP compiler as a student project for my Comiler Design course at
> University (I, as a group leader, have 10 people and 4 months on my
> hands to build a comiler of my own). So, it would be very nice to have
> "nobody did it before" in my project documentation. And I can write that
> if I'm not sure, right?
>
> --
> Pozdrav/Regards, Nikola [Nick] Skoric.
> "...Usne, tice-rugalice - a u oku tajac
> Da sam kaput sa dva lica, da sam Gospo'n Propalica..."
> http://newusers.cjb.net/ - site o Usenetu na hrvatskom!

If I may say, if you have never written a compiler before, do attempt a php
compiler, stick to a language that is more suited for compiling.

PHP has too many functions, that can limit compiling, for example, the
require() function can be used like a C-style include, and compiled, but you
lose out on the include() function, becouse a lot of time people need to
include editable (such as forms erc..) files at run time, therefore those
files can not be compiled. Actualy even some require() files can not be
compiled, becouse they contain config variables that need to be editied by
the user.

 So you compiler would have to have some added directives to tell it whether
to compile the require/include files, and it would have to have a built in
interpeter in the run time, so as to interpet the include files that were
not compiled. (also file scripts that use the eval command)

Here is an example:

main file:
<?php
  include("sub.php");
  print "Version: $ver\n";
  print "Max allowed users: $maxUsers\n";
?>

include file, that can not be compiled becouse user has to define settings
sub.php
<?php
    $ver = "1.0";
    $maxUsers = 20;
?>

Also, there are a lot of people (my self included) that write admin pages
that write php config pages, that are included in a script, I also write
selfmodifying scripts.

Now I am not saying it can not be done, just rather complex due to the
robustness of php. This is why alot of compilers compile to P-Code. not true
cpu instructions.

Well you have one good advantage, you have access to the php source :)

Just my 2 cents.

--
Mike Bradley
http://www.gzentools.com  -- free online php tools


Relevant Pages

  • RE: [PHP] Securing PHP code..
    ... developer, the aspect of reverse engineering code from ... developing PHP scripts on large scale I have started to think ... There is at least one very young PHP compiler ...
    (php.general)
  • Re: Delphi has ruined me. Ruined, I tell you, ruined.
    ... With no compiler, its the gateway drug to bad programming. ... I guess I should start going around to websites and hacking ... type PHP habitual programming for constructive purposes. ... But this does go beyond just compiler type checking. ...
    (borland.public.delphi.non-technical)
  • Re: [SOLVED] php5-mysql? (with added bonus for snort)
    ... make install of php5 and of mysql but no luck so far. ... Configured with: FreeBSD/i386 system compiler ... configure:2823: checking build system type ... configure:2974: checking for PHP includes ...
    (freebsd-questions)
  • Re: Compiled PHP Questions
    ... > eyes so that I can deploy custom web-applications on a customer's ... That is the problem with PHP. ... PHP was developed as an open-source ... compiler produces is identical to the one cached PHP code has. ...
    (alt.php)
  • Re: PHP compiler
    ... Anybody can develop a compiler that ... i did this with a lisp interpreter in my ... but using PHP in a compiler course. ... interpreted by the Zend engine, that is also a compiler tool to me. ...
    (comp.lang.php)