How to run PHP in Sublime Text
To run PHP with Sublime Text, please perform the following steps:
1. Install Sublime Text Build System
- Open Sublime Text.
- Go to Tools >Build System.
- Select "PHP" from the drop-down menu.
2. Save the PHP file
- Use Sublime Text to create or open a PHP file.
- Save the file extension as
.php
.
3. Run the PHP script
- To run the PHP script from the command line, use the following command:
<code>php <php_file_name.php></code>
Copy after login
- To run a PHP script from Sublime Text, do the following:
<code>* 选择“工具”(Tools)>“构建”(Build)。
* 选择“运行”(Run)。
* PHP 脚本将在终端窗口中运行。</code>
Copy after login
4. Set the PHP path
If Sublime Text cannot Find the PHP executable file, you need to set the PHP path.
- Open Sublime Text.
- Go to Preferences >Settings.
- In the User Settings JSON file, add the following line:
<code>"php_path": "/path/to/php"</code>
Copy after login
- Replace
/path/to/php
Is the actual path to the PHP executable file.
5. Use shortcut keys
You can use shortcut keys to run PHP scripts faster:
-
Ctrl B (Windows/Linux) or Cmd B (Mac): Run in Terminal
-
Ctrl Alt B (Windows/Linux) Or Cmd Option B (Mac): Run in Sublime Text
Note:
- Make sure PHP is properly installed in your system.
- If you have problems running PHP scripts, check the terminal window for error messages.
- Sublime Text can also use other build systems to run PHP scripts.
The above is the detailed content of How to run php in sublime. For more information, please follow other related articles on the PHP Chinese website!