How I can run PHP script without PHP Server like PHP Triad, Xampp, etc.
I think it is simpler and more flexible.
Thanks for sharing.
Just download propper php-5.x.x-Win32.zip from http://php.net/download unpack it to c:\php\
then just run cmd.exe and type
| Code: |
| c:\php\php.exe "path where you have your script.php" |
this will execute the script and it will prints script output to console
if you want to save this output to file, just type
| Code: |
| c:\php\php.exe "your_script.php" > output.html |
then open output.html with your favourite web browser
if you want tu use this more then once, you should add c:\php\ to your PATH environment variable. Than you can lounch any php script by typing
| Code: |
| php "your_script.php" |
in any folder
Actually, if you use c:\php\php.exe, you will get html output, and this is more optimized towards handling http requests. There is a client version of the interpreter which is bundled with php. This outputs text to console. It will be available at C:\php\cli\php.exe (assuming you installed php under c:\php).
| kv wrote: |
| Actually, if you use c:\php\php.exe, you will get html output, and this is more optimized towards handling http requests. There is a client version of the interpreter which is bundled with php. This outputs text to console. It will be available at C:\php\cli\php.exe (assuming you installed php under c:\php). |
No. This was.
PHP 5.2.x discard this mass.
You have everything in PHP root directory
php.exe - console output
php-cgi.exe - handling requests (with cgi mode of HTTP server), which also put HTTP header
php-win.exe - the same as php.exe, but it don't create any console window (it is good to run scripts at background without text output)
as it is written here
| Quote: |
| How I can run PHP script without PHP Server like PHP Triad, Xampp, etc. |
There's no such thing as a 'php sever' - php, as the name implies, is a processor. And when you install php by default (i.e. not linked to a webserver) it's php-cli, which is the command-line interface.
| Quote: |
| Actually, if you use c:\php\php.exe, you will get html output |
No, you won't. You'll get html output if you output <html>. Why not actually check things before you say them?
Thank u but can we run python scripts with out python server ???
| badea wrote: |
| Thank u but can we run python scripts with out python server ??? |
What is python server???
| simplyw00x wrote: |
| Quote: | | Actually, if you use c:\php\php.exe, you will get html output |
No, you won't. You'll get html output if you output <html>. Why not actually check things before you say them? |
when I said html output, I didn't mean the string "html". I meant http headers, which are not output the client version of interpreter (cli/php.exe).
when you run this code,
client version gives output
where as the web version outputs
| Code: |
X-Powered-By: PHP/4.4.2
Content-type: text/html
test
|
| Quote: |
| where as the web version outputs |
I humbly disagree. On my setup, they appear to be processed identically.
| Quote: |
| Thank u but can we run python scripts with out python server ??? |
You can't run python scripts without python. Whether it's a server is open to debate.
Sorry to barge in like this, but I have a relevant question.
As you can run php in such a way, is there any way to do the same with MySQL, so that you can also simulate, or actually perform, database modifications without setting your computer up as a server?
| ninjakannon wrote: |
Sorry to barge in like this, but I have a relevant question.
As you can run php in such a way, is there any way to do the same with MySQL, so that you can also simulate, or actually perform, database modifications without setting your computer up as a server? |
You can't access mysql database without server. MySQL and other DBMSs are designed to work as client-server. One server is still running and manage all accesses to the database files.
If you want SQL database without server try SQLite http://www.sqlite.org It is small library and it doesn't need any server.
| JayBee wrote: |
| You can't access mysql database without server. MySQL and other DBMSs are designed to work as client-server. One server is still running and manage all accesses to the database files. |
Yeah, I didn't think it was possible. But I only asked because I didn't think that you could run php files without them being on a server where php is installed, and you can. So I had doubts.
| JayBee wrote: |
| If you want SQL database without server try SQLite http://www.sqlite.org It is small library and it doesn't need any server. |
I don't quite understand how this works. If I install the program how do I connect to it with php and how does it store databases, etcetera.
Thanks once again, JayBee. 
| ninjakannon wrote: |
| Yeah, I didn't think it was possible. But I only asked because I didn't think that you could run php files without them being on a server where php is installed, and you can. So I had doubts. |
PHP must be installed, but apache (or other http server should not)
| ninjakannon wrote: |
| JayBee wrote: | | If you want SQL database without server try SQLite http://www.sqlite.org It is small library and it doesn't need any server. | I don't quite understand how this works. If I install the program how do I connect to it with php and how does it store databases, etcetera.
Thanks once again, JayBee.  |
PHP has build in support for SQLite 2 or SQlite 3 throw PDO (just download pecl package and enable it in php.ini)
It works like you open -> read/write -> close regular file but it is safer and with SQL support. You have one file with database wherever you want.
Similar features are with dba_ functions, but with this driver, you don't have SQL to access data.
With sqlite_ functions (similar set to mysql_ functions), you work with SQL database, but everything is directly handled with PHP not with another database server.
http://php.net/manual/en/ref.sqlite.php
http://php.net/manual/en/ref.pdo-sqlite.php
http://php.net/manual/en/ref.pdo.php
Oh I see now - thank you very much.
I'm seriously considering installing both php and SQLite so that I can experiment / test with php and a database even without an internet connection (mine cuts automatically every day).
What are the limitations of doing this, instead of running scripts on a normal server with MySQL?
Now it's really off topic
1) You can install your own mysql and work with your local mysql server without internet connection.
2) I don't know any limitations notable here
Ohh, I never thought of that! Just simply installing MySQL itself. I even downloaded the files for it a while ago when I was on another computer to do exactly that, but forgot all about it. Heh, silly me.
| JayBee wrote: |
Now it's really off topic  |
Yeah we are.
Anyhow, I know all I need now so we need not stay off-topic any longer, and thank you! 
| Quote: |
| What are the limitations of doing this |
Limitations of sqlite are that it's slower than mySQl, and afaik less feature-complete.
| simplyw00x wrote: |
| Quote: | | What are the limitations of doing this |
Limitations of sqlite are that it's slower than mySQl, and afaik less feature-complete. |
Okay, thank you, simplyw00x.
I did wonder whether it would be less feature complete, but I don't expect this to be a problem. And I don't mind it taking slightly longer either, so that's good. 