Forum Moderators: coopster

Message Too Old, No Replies

php as an executable file

         

aznbruinboy

6:00 pm on Jul 14, 2004 (gmt 0)

10+ Year Member



hey everyone, i was wondering, how to write a php file, and turn it into an executable file that can be run.

i.e. if i write some code in php, and i want it to be a program that runs in the background... say, listens for information that comes in the sockets.

how would I implement this? also, how would i make the php file into an executable that doesn't need to be opened from internet explorer?

e.g. like in c++ you would compile the source code and an exe file would result. however, this is not the case with php. what could i do to make the server run the php code without requiring me to open it in the browser?

I am confused. thanks a lot!

rlkanter

9:16 pm on Jul 14, 2004 (gmt 0)

10+ Year Member



Under *nix at least you can simply flag the file as executable and then insert the location of your php executable in the first line (similar to what you do with perl scripts). Theres no need to compile it although there is at least one program out there that does make compiled php programs (the compiler is linux only and in the neighborhood of $400/yr.)

As far as listening to a socket, I wouldn't know where to begin, but here is how to execute the php script.

For example script test.php:
chmod a+x test.php

test.php:
#!/usr/local/apache/bin/php -q
<?php
echo 'Test';
?>

Dimac Grandmaster

3:42 am on Jul 15, 2004 (gmt 0)

10+ Year Member



PHP is a server-side SCRIPTING language. It doesn't get compiled. That is what the PHP engine is for. If you want an active executable like the one oyu describe then I would recommend looking at Python.

aznbruinboy

6:24 am on Jul 15, 2004 (gmt 0)

10+ Year Member



but what if i'm doing this under windows?

aznbruinboy

6:29 am on Jul 15, 2004 (gmt 0)

10+ Year Member



basically i'm trying to understand this tutorial -

[zend.com...]

and what i don't get is the pragraph which says
"In order to run the program, make sure that the first line #!/usr/local/bin/php –q is the location of the PHP CLI (or CGI) binary. You will need to change the mode so it is executable (chmod 755 socket_server.php – where socket_server.php is the name of the file) and run it using ./socket_server.php
from the command line."

Since i am using a windows system, how do i access the command line?

i don't really understand the prerequisites either. i am running an apache server with php support. erm.. i'm sorta new at this. haha thanks for the help!