You can also perform some algorithm operations. At the same time, PHP is mainly used in web application development. PHP has a low entry threshold, is easy to learn, and is widely used. It is mainly suitable for the field of web development. The file extension of PHP is php.
What is a php file?
How to open a php file? PHP is abbreviated as Hypertext Preprocessor. The Chinese name is hypertext preprocessor. It can perform some algorithm operations like c, c++, java, and perl. At the same time, php is mainly used in web application development. , PHP has a low entry threshold, is easy to learn, is widely used, and is mainly suitable for the field of Web development. The file extension of PHP is php.
How to open php file?
The method to open php files is very simple. We can directly use Notepad text to open it. If it is a WEB development application, we can use dw Notepad ++ Eclipse PDT Notepad2, etc. to open it. This kind of opening can only view the source. The file cannot be executed.
How to run php files
As mentioned earlier, php is a programming language in the field of web development. We need the support of the php environment to run it.
What are the PHP environments?
PHP can run in windows or linux. The supported environment in windows is iis+php or apache+php environment
I can also use apache+php or nginx+php environment in linux
How to configure the php environment
iis+php environment configuration method
1> Unzip to the c:/php directory.
Open the c:/php directory and find the php.ini-dist file. Rename it to php.ini.
2> Open the php.ini file.
Find the line ;include_path = ".;c:/php/includes".
Modify to include_path = "c:/php/includes"
Find extension_dir = "./"
Modify to extension_dir = "c:/php/ext"
Found ;extension=php_mysql.dll
Modified to extension=php_mysql.dll
Found ;session.save_path = "/tmp"
Modify to session.save_path = "c:/winnt/temp"
If the operating system is win2003, it will be "c:/windows/temp"
php.ini is provided in this directory and can be used directly. Applicable to windows2000.
3> Copy php.ini to c:/winnt
Copy libmysql.dll to c:/winnt/system32
4> Create a new directory d:/forphp as the test php website directory.
Create a new notepad file in this directory and rename it to index.php. The content is: There is index.php in this directory for use.
5> Make sure that the Iusr_mochinename user has full control permissions on d:/forphp.
Has read and run permissions on c:/php. (If the d drive is in fat32 file system format, there is no need to set the d:/forphp permissions)
6> Open iis manager.
Create a new web site. Point to the d:/forphp directory. Specify the site host header arbitrarily. (For convenience of browsing, use the local IP)
7> Right-click the site--Properties--"Home Directory" option.
Click "Configuration" below. "Application Configuration" pops up, click "Add". Executable file, browse to select c:/php/php5isapi.dll and confirm. Extension write .php
8> Restart IIS. You can realize that the iis site supports php scripts.
Settings for coexistence of PHP and IIS
The first step is to unzip the PHP5.0 compressed package and place it under C:/PHP5.
The second step is to copy the php.ini-dist file under C:/PHP5 to the WINNT directory and rename it to php.ini. You don't need to modify any parameters to run it. Of course, you can modify some parameters according to different situations.
The third step is to copy C:/PHP5/php5ts.dll to the C:/WINNT/system32 directory.
The fourth step is to start computer management.
Step 5: Expand "Services and Applications"/"Internet Information Services" on the computer management window, right-click on "Default Web Site" and select Properties. The system will pop up "Default Web Site Properties" Window:
Step 7: Click the "ISAPI Filter" tab on the "Default Web Site Properties" window, click the "Add" button, and enter "PHP" in the "Filter Name" of the pop-up "Filter Properties" window. ”, enter “C:/PHP5/sapi/php5isapi.dll” in “Executable File”, and confirm.
Step 8: Click the "Home Directory" tab in the "Default Web Site Properties" window, click the "Configure" button, click the "Add" button in the pop-up "Application Configuration" window, and click the "Add" button in the pop-up "Application Configuration" window. In the "Add/Edit Application Extension Image" dialog box, enter "C:/PHP5/sapi/php5isapi.dll" in the "Executable File" text box and ".php" in the "Extension" text box (Note There must be that point), sure.
Step 9: Open the command line window and enter the "net stop iisadmin" command to terminate the IIS service. The system will ask you if you want to stop related services, answer yes. Wait until they are all closed.
Step 10, enter the "net start w3svc" command to restart the IIS service.
apache configuration php environment
1. We install the apache environment on the computer,
2. Then we download the php version and unzip it in the C: drive php directory
Then we add
immediately after apacheLoadModule php5_module "c:/php5/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "c:/php5"
Restart apache and the configuration will be ready
Then we create a website and put the php file in the website directory to run it. The code is as follows
define("test","HELLO WORLD!");
echo test
?>
Output is
HELLO WORLD
Friendly reminder, this article only briefly introduces what kind of file php is, and also attaches some ideas for opening php files and letting php run. Specifically, if we want to actually run php, we need to configure the apache environment in more detail. That’s okay, because the real application also requires the installation and configuration of the mysql database.