Home >Backend Development >PHP Tutorial >PHP we learned together in those years (1), learn PHP (_PHP tutorial
PHP is the abbreviation of the English hypertext preprocessing language Hypertext Preprocessor. PHP is an HTML embedded The language is a scripting language that is embedded in HTML documents and is executed on the server side. The language style is similar to the C language and is widely used. Since the creation of the PHP language in 1994, it has been miraculously sought after as the first choice for website design. Language. The release of PHP 4.0 in 2000 undoubtedly injected new life into it, and it was also respected for its open source mentality. Learning the programming language is nothing more than learning some syntax and basic application examples. Record the PHP process step by step, firstly, to summarize yourself, and secondly, to help future learners who encounter the same problem
.Note-taking is mainly in the form of questions. It will not explore the basics of language bit by bit like a book-based class. Mainly in the basic stage of PHP learning, the problems are foreseen and solved one by one, recorded, and the process of never understanding the solution is recorded. Well that's where the real PHP language begins.
1): What kind of development environment and development tools does PHP need?
Regarding the PHP language version issue, it is necessary to understand it, but I think it doesn’t matter much. Baidu/google can find these development version issues. If a worker wants to do his job well, he must choose a sharp tool! The first time is to configure the development environment. The development environment I first came into contact with was windows, but this time I am willing to conduct subsequent studies on Linux. Now I will show the deployment of both development environments once.
2): What are the steps for windows installation? What aspects need to be paid attention to?
The first is windows. Generally, for convenience, you will choose to install a tool suite on windows. Here I use WampServer for development. Wamp is the Windows Apache Mysql PHP integrated installation environment, that is, apache, php and mysql under windows. Server software. Simple one-click installation and deployment of servers, databases, etc. without having to think too much. You can proceed directly to the next step. However, please pay attention to the following points during the installation process:
1. The path where the WAMPSERVER program is located cannot contain Chinese characters and spaces.
2, mysql default user name: root, the password is empty
3, mysql database file storage directory: wampbinmysqlmysql5.5.8data
4. Website root directory [HTML, PHP]wampwww
5. Visit this machine, please use http://127.0.0.1/ (if port 80 is not occupied)
6. Non -default port, the URL is http://127.0.0.1: port/
If an IIS server is installed, port 80 is occupied by default. You need to change the wamp service Internet port number: There is a Listen node with the file httpd.conf in the C:wampbinapacheApache2.2.17conf folder. Modify the port number 80, or you required. After modification, restart all services and run them.
Development tools: PHP Development tools: Zend Stodio, PHPedit, EditPlus 2, easyeclipse, DW, etc. can be completed. As an inherited development tool, Zend is easier to use.
3): Is the installation package deployment environment also in the Linux environment? Is there a graphical management interface?
However, we can still develop PHP on Linux. The development environment I choose here is LAMP (linux Apache Mysql PHP). I use the Ubuntu distribution version as an example to install the development environment. The Apache official website card can download the offline installation package or install it online. It is more convenient to choose online installation here. First use the Ubuntu system and enter the window command (Ctrl Alt t)
Apache installation
As a powerful Web program, Apache is naturally the first choice for building a Web server. Well, let’s install Apache. Enter the following command in the terminal:
sudo apt-get install apache2
After the installation is completed, the next step is to start Apache
sudo /etc/init.d/apache2 restart
Browse Enter http://localhost or http://127.0.0.1 into the server. If you see "It works!", it means that Apache is successfully installed. The default installation of Apache will create a name under /var. It is the directory of www. This is the Web directory. All Web files that need to be accessible through the browser must be placed in this directory.
Installation of PHP
Installing software under Ubuntu is a very simple matter. It only requires one command. Execute the following command in the terminal:
sudo apt- get install libapache2-mod-php5 php5
After installation, we need to restart Apache and let it load the PHP module:
sudo /etc/init.d/apache2 restart
Next, we will Create a new PHP file under the directory to test whether PHP can run normally. Command:
sudo gedit /var/www/phpinfo.php
Then enter:
(Note: Replace bloginfo with phpinfo when using it. Due to server restrictions, the phpinfo function cannot be used)
Then save the file and enter http://127.0.0.1/phpinfo.php in the browser. If a display appears PHP running parameters page, it means that PHP is running normally.
But if the page is not displayed, but you are prompted to download the file, it means that Apaceh has not loaded the PHP module correctly. The solution is to add it to /etc/apache2/apache2.conf or Add the following line of command to the /etc/apache2/mods-enabled/php5.conf file:
AddType application/x-httpd-php .php .phtml .php3
After adding the above command, pass the following The command should restart Apaceh and the problem should be solved:
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 restart
There is a situation where the expected page does not appear. It may be that the folder www does not have appropriate access permissions. You can change the permissions of the www folder through sudo chmod x ./www. (Those who are familiar with Linux permission management should know this)
MySQL installation
sudo apt-get install mysql-server
At the end of the installation, it will ask you to enter the root password , note that the root password here is not the Ubuntu root password, it is the root password you want to set for MySQL. Of course, if you are willing, you can set it to the same value. Because it is mainly used for local testing, MySQL has been installed here. If it is really going to be used as a server, you may need to refer to other settings. As for these settings, I will use them later. written down.
Okay, the installation of the development environment is over, let’s wait to write a program that complies with the rules!