Page 1 of 1

How would I execute a PHP command?

Posted: Sat Sep 10, 2005 5:00 pm
by roachofdeath
I am trying to think about ways to execute a PHP file or command silently. Any suggestions?

Posted: Sat Sep 10, 2005 5:01 pm
by Jellybean

Code: Select all

RunProgram("php.exe", "filename", "c:\diroffilename\", 1|2)
?

Posted: Sat Sep 10, 2005 5:51 pm
by ricardo
You need to download php or ActivePhp to be able to run it in your computer.

if you are looking for PHP string commands only, as far as i can remember there is some lib on purearea.net about that, but is not running php, for real php only have php installed on your PC.

Posted: Sat Sep 10, 2005 7:15 pm
by Jellybean
I think (at least I hope) he knows that he needs to have php installed. :? :lol:

Posted: Sat Sep 10, 2005 7:25 pm
by roachofdeath
im not reatarded, and I know PHP

here is what im talking about...

for example if i somehow tell purebasic to execute:

Code: Select all

<?PHP
$f=fopen("whatever.txt","w");
echo fwrite($f,"C:\TestFile.txt");
fclose($f);
?>
then i wish for it to execute the code, and create the .txt file. I don't want to do that exactly, but that's what I mean

Posted: Sat Sep 10, 2005 7:32 pm
by ricardo
If you have PHP installed, if your webserver are properly configurated and if this PHP code its okay, should work fine.

One question: you need to do it in PHP?
I mean, if you are using a PB coded webbrowser, you can do the same without using PHP and will be easier and your distributable file will be smaller since dont need PHP.

Posted: Sat Sep 10, 2005 7:39 pm
by ricardo
roachofdeath wrote: for example if i somehow tell purebasic to execute
PB dont execute PHP.

If you have PHP installed, and configure your web server fine, when it receives a call to a .php page, it will sent it to PHP.exe on your computer and only receive the result from php.exe and send it to the client.

Its the same as a CGI, the server call the appropiate executable to interpret the code and receive the response (code already interpreted) from .exe

Posted: Sat Sep 10, 2005 8:39 pm
by benny
You could execute your example code snippet

Test.php

Code: Select all

<?PHP
$f=fopen("whatever.txt","w");
echo fwrite($f,"C:\TestFile.txt");
fclose($f);
?>
by using PB-Runcommand even without running a webserver. Just try
to execute the php.exe like this :

Code: Select all

[pathTOphp]/php.exe -q -f Test.php
That would execute above's PHP-Code.

To get the output (i.e. the result of fwrite) you could use the
following:

Code: Select all

php.exe -q -f Test.php > Test.html

Test.html now stores the output of the "echo fwrite()" command.


Maybe this info is of some help for you :?: :!:

Posted: Sat Sep 10, 2005 8:59 pm
by pantsonhead
hey roach,

I assume you are calling php from commandline (not in a browser).
Not many folks use php this way but it's great. I converted a bunch of VB file/mail processing applications to php and they run about 8 times faster.

If you aren't using commandline php then do it, and refer to Jellybean's post above.

EDIT : looks like Benny types faster than me

Posted: Sat Sep 10, 2005 10:27 pm
by ricardo
The problem will be that is building static pages and if you have multiple clients could have problems.

Calling from iniside PB server, like a CGI makes it handle just like any other server: dynamic content.

Posted: Sun Sep 11, 2005 7:50 am
by dagcrack
well in fact things could be done anyway if he has a queue list, then he'll be able to process every "client" and have the other awaiting till that one is done, then the next one, on the barber shop to get that fancy new cut he wanted! - Depends on what hes going to programm though.

I guess that now hes able to do what he wanted - why speculating?

Posted: Sun Sep 11, 2005 2:07 pm
by roachofdeath
benny, that seems about what I wanted to do in the first place, but I was unsucsessful finding the php exe. Whenever I try to run a PHP file, it just has me download it :|

Posted: Sun Sep 11, 2005 5:59 pm
by griz
Roach, have you checked out my 'php brew' code here on the forums?

viewtopic.php?t=13982&highlight=

Does this help?