While traditionally PHP scripts are run by web servers, it is possible to run them through Sublime. To set up a webserver, I suggest you to read this: http://www.ntu.edu.sg/home/ehchua/programming/howto/WampServer_HowTo.html
It will get you started on how to setup a local server and 'run' PHP.
If you want to run PHP from your Sublime Text 2/3 console you should go to:
Tools -> Build System -> New Build System...
and then edit the file like this:
{
"cmd": ["/path/to/php", "$file"]
}
where /path/to/php
is something like /usr/local/bin/php
on Linux/OS X or C:/WAMP/bin/php.exe
on Windows (make sure to use forward slashes /
). Save the file as Packages/User/PHP.sublime-build
where Packages
is the folder opened when you select Preferences -> Browse Packages...
. Next, click on Tools -> Build System -> PHP
and hit Ctrl+B to run your script (or Cmd+B on a Mac). You should see the output, if any, in the build console that opens.
Be sure there aren't any errors in your PHP and also be sure that PHP is configured correctly!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…