Home  >  Article  >  Backend Development  >  PHP study notes--Building a PHP development environment---A Dong's column

PHP study notes--Building a PHP development environment---A Dong's column

WBOY
WBOYOriginal
2016-07-29 09:14:58996browse
PHP study notes - start by building a PHP development environment

When it comes to PHP, the first thing that comes to my mind is the scene in "The Social Network" in which Mark uses PHP to write Facemash in his dormitory. This is one of the reasons why I learned PHP. I won’t go into too much detail about the advantages of PHP. Just take a look at the famous domestic and foreign websites that use PHP+MySQL technology. To learn a language, you have to start by setting up a development environment.

  I am using the Windows 7 operating system. To build a PHP development environment on the Windows platform, you can download the WAMP (acronym for Windows, Apache, MySQL, and PHP) integrated installation package. This eliminates the need to install Apache, MySQL and PHP separately. Since some people’s computers have IIS installed, the default port of IIS is port 80 and Apache also uses port 80. There is more than one way to resolve the conflict. You can modify the httpd.conf file in the Apache installation directory and stop Use IIS, etc. The method I personally use is to change the default port of IIS to port 81. The method is as follows, open the IIS manager and select "Default Web Site", click "Bind" on the right to modify the port. PHP study notes--Building a PHP development environment---A Dongs column

Run wampServer, click Apache, there is a test port 80 in the Service directory. In addition to IIS, there are many software that can Occupy port 80, such as Thunder and Kugou. After solving the port conflict problem, you need to make relevant settings for PHP. Check the "short open tag" and remove the check in front of "display errors". Tags like ?> are supported.

PHP study notes--Building a PHP development environment---A Dongs column

As for the IDE, I currently use eclipse, and the ones with good reputation include zend studio and so on. First, let’s introduce how to make eclipse support PHP. Download an eclipse first. After the installation is complete, run eclipse and find "Instal New Software" under Help in the main interface. Then select "All Available Sites" in Work with. After a while, find PDT in "programming language" and go all the way to NEXT.

PHP study notes--Building a PHP development environment---A Dongs column

 After installing PDT, you can use eclipse to write PHP

 Let me talk about a doubt I encountered during my study today. . Take a look at the code first: PHP study notes--Building a PHP development environment---A Dongs column

PHP study notes--Building a PHP development environment---A Dongs column

1

PHP study notes--Building a PHP development environment---A Dongs column2

3

4

5

6

78

9

10

11

12

13

14

15

16

    include("conn.php");

    if($_POST['submit'])//1

    {

        $sql="insert into message(id,user,title,content,lastdate)".

        "values('','$_POST[user]','$_POST[title]','$_POST[content]',now())";//2

        mysql_query($sql);

echo "Submitted!" ";

}} ? & Gt;

"add.php" method="post">

用户:"text" name="user">

标题:"text" name="title">

内容:

"submit" name="submit" value="提交">

Looking carefully at the code at places 1 and 2, you can find that there is a single quote before and after submit in place 1, but there are no single quotes in place 2 such as user. If you remove the single quotation mark in place 1, the program will issue a warning, but if you add single quotes in place 2, an error will be reported. Why is this?

In fact, it doesn’t make much difference whether to add single quotes or not. The only difference is that adding single quotes is more efficient than adding no quotes. The reason is that for $_POST[submit] without single quotes, PHP will first check whether the constant submit is defined in the full text of PHP. If it cannot be found, Only then will submit be regarded as a string, and then look for the value of $_POST['submit']; and if quotation marks are added, there will be no step of judging whether submit is a constant, but directly look for $_POST['submit ']; therefore, it is best to add quotation marks everywhere. As for the error of adding single quotation marks in the sql statement, it is in the sql statement. Single quotation marks have been used outside and single quotation marks are used inside. Naturally, it will This causes an error in the SQL statement, in which case slash escaping is required.

The above introduces the PHP study notes - building a PHP development environment - A Dong's column, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn