0

I heard that PHP can be used without a web server, and it executes like C++ or Java. How can I do that? What program do I use?

1

7 Answers 7

1

You should install PHP on your PC, than you may run php via

/path/to/php /path/to/script.php

on your console.

Besides, on *nix systems you may made it executable (chmod) and add

#!/path/to/php

to head of your script. It will allow you to run it by just calling script

Sign up to request clarification or add additional context in comments.

Comments

0

That's PHP CLI. Command line usage.

Here's all you need http://php.net/manual/en/features.commandline.php

If you're on windows you run a file :

php.exe -f myfile.php

Comments

0

PHP can be used as a command line scripting language.

Comments

0

php comes with a php executable (on debian systems, you need to install the package php5-cli). Then, either write a file test.php and execute it on the command line with php test.php, or use the -r argument for short one-liners:

$ php -r 'echo date("%c") . "\n";'
%2011-10-12T00:29:39+02:00

If the executable is not in your PATH, you need to give the full path to php, like /usr/local/bin/php.

Comments

0

PHP can be executed via command line, but if you're thinking of a GUI or something, that's different. You'd basically be building a website. I don't think you'll be creating native Windows, Mac OSX, iPhone or Android apps any time soon with PHP.

If you want a way to compile PHP, check this out:

http://www.roadsend.com/home/index.php?pageID=compiler

Either way, if you want to run it like C++ or Java, you'll still need PHP on your system as an interpreter. I don't believe you can get around that.

1 Comment

PHP can be used to code GUI dekstop application, using PHP-GTK library.
0

Yes, you can use php in a stand-alone fashion. How you obtain a command-line version depends a bit on your platform, in fedora, you can su -c 'yum install php-cli', and then you will have a program called php to run your scripts.

Comments

0

Doing this entails, if you're on Linux, creating a bash-like script where you specify the PHP interpreter at the top of the file, like this:

#! /your/path/to/php -q

See: http://www.ibm.com/developerworks/opensource/library/os-php-command/

Or just

/your/path/to/php /my/php.file

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.