Tutorial on setting up and using PHP environment in IJ

Table of contents

Table of contents

Preface

mind Mapping

1. PHP environment download

1. Download link

2. Install

3. Custom path 

4. Select and download some related libraries.

2. Configure the PHP environment in IJ

2.1, Download PHP plug-in

2.2, Things to note during downloading 

3. Why do you do this?

3.1, reasons

3.2, conduct code testing:

4. Network Security PHP Basic Assignment 4

4.1, title

4.2, Internet Security Assignment 1 Code Interpretation:

4.3, Result display:

5, Internet security homework 2

5.1, title:

5.2, code interpretation:

5.3, Result display:

 6.Network Security Assignment 2

6.1, title:

6.2, code interpretation

6.3, Result display

7. Summary


Preface

This chapter is about two programming languages ​​that we need to understand in the process of learning network security. What we are going to do today is one of them. This article is about setting up the environment and writing it when I am learning PHP. .

mind Mapping

1. PHP environment download

1. Download link

https://sourceforge.net/projects/wampserver/icon-default.png?t=N7T8https://sourceforge.net/projects/wampserver/

                                     We click on the link to enter the page shown in the picture and download it.

2. Install

                              After downloading, it is the exe file as shown in the picture, double-click it.

3. Custom path 

4. Select and download some related libraries.

                 Here we can download the version we want ourselves, because this is an integrated platform

                                             Then we click Next

              Our installation is done here. Next, we configure the php environment in IJ.

2. Configure the PHP environment in IJ

2.1, Download PHP plug-in

        We download the PHP plug-in in IJ. This plug-in is not required in IJ. You need to search and download it yourself.

2.2, Things to note during downloading 

                                     Here we need to configure the CLI interpreter

Then, we click on the file in the upper left corner of IJ --> then click Settings --> first click Language and Framework --> then click PHP, and finally we choose to install the php file in the bin directory of the custom-installed software. php.exe file in

3. Why do you do this?

3.1, reasons

The reason is: after the configuration is completed, we can click on the upper right corner of the code directory page in IJ to enter the web page. There is no need to build a server or other or use Xiaopi to configure the local server.

3.2, conduct code testing:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>PhP测试</title>
</head>
<body>
<?php
  $arr = [1,2,3,4,5];
  print_r($arr);
?>
</body>
</html>

4. Network Security PHP Basic Assignment 4

4.1, title

Write a human Person: Attributes in the class: Name. Gender. Age. Height. Weight. Date of birth. Methods in the class: 1. A human’s self-description method: Output all relevant attributes of the human. Test: Generate a Person object p, the object's name "Wang Ermazi", gender "male", age "17", height "176.5", weight "73.5", date of birth "1997/9/23", and finally call the object's self-description method

4.2, Internet Security Assignment 1 Code Interpretation:

Here we first create a Person class. Then we define the attributes, where

In PHP classes, public variables are an access modifier that defines member variables (properties) that can be accessed both inside and outside the class. When variables are declared public, they can be directly accessed and modified by objects of other classes. This means there is no need to access or modify them through the class's methods.

Then we define a method to print out the attribute information. Next, we instantiate the class, then instantiate the attributes in the class (which can be seen as assigning values), and finally call the method to transfer the instance to Information about the object is printed out. 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>PhP测试</title>
</head>
<body>
<?php
//创建一个Person类
class Person{
    // 姓名. 性别. 年龄. 身高. 体重. 出生年月
    // 语法格式: public 属性名
    public $name;
    public $gender;
    public $age;
    public $height;
    public $weight;
    public $birthDate;
    // 类中的方法: 1. 一个人类的自我描述方法: 输出该人类的所有相关属性
    //语法格式 public function 方法名(){代码块}
    //在PHP中,点号(.)被用作字符串连接操作符,也称为字符串拼接符。
    //$this->和python中的self相似 后面是换行符使用拼接符.进行链接
    public function describe() {
        echo "姓名:" . $this->name . "<br>";
        echo "性别:" . $this->gender . "<br>";
        echo "年龄:" . $this->age . "<br>";
        echo "身高:" . $this->height . "<br>";
        echo "体重:" . $this->weight . "<br>";
        echo "出生年月:" . $this->birthDate . "<br>";
    }
}
// 创建一个Person对象并设置属性,使用python中类的知识来理解,面向对象语法基本一致
$p = new Person(); //进行类的实例化
$p->name = "王二麻子";
$p->gender = "男";
$p->age = "17";
$p->height = "176.5";
$p->weight = "73.5";
$p->birthDate = "1997/9/23";

// 调用对象的自我描述方法
$p->describe(); //进行方法的调用
?>
</body>
</html>

4.3, Result display:

5, Internet security homework 2

5.1, title:

Write a dog class: Attributes in the class: name, gender, color, breed, weight, shoulder height, price Methods in the class: 1. Introduction method of a dog class: Output all information about the dog class Test: Generate a Dog Object b, the name of the object is "Aba", the gender is "female", the color is "brown-red", the breed is "Teddy", the weight is "5.2" kilograms, the shoulder height is "26", and the price is "2000" to generate a Dog object t , the object's name is "rabbit", gender is "female", color is "silver gray", breed is "Teddy", weight is "3.1" kilograms, shoulder height is "22", price is "5000"

5.2, code interpretation:

       I won’t go into too much code interpretation here. The types of the remaining two questions are the same as the first one.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>PhP测试</title>
</head>
<body>
<?php
class Dog {
    public $name;
    public $gender;
    public $color;
    public $breed;
    public $weight;
    public $shoulderHeight;
    public $price;

    public function introduce() {
        echo "姓名:" . $this->name . "<br>";
        echo "性别:" . $this->gender . "<br>";
        echo "颜色:" . $this->color . "<br>";
        echo "品种:" . $this->breed . "<br>";
        echo "体重:" . $this->weight . "斤<br>";
        echo "肩高:" . $this->shoulderHeight . "<br>";
        echo "价钱:" . $this->price . "<br>";
    }
}

// 创建一个Dog对象并设置属性
$b = new Dog();
$b->name = "阿八";
$b->gender = "母";
$b->color = "棕红";
$b->breed = "泰迪";
$b->weight = "5.2";
$b->shoulderHeight = "26";
$b->price = "2000";

// 输出狗类的所有信息
$b->introduce();

// 创建另一个Dog对象并设置属性
$t = new Dog();
$t->name = "兔子";
$t->gender = "母";
$t->color = "银灰";
$t->breed = "泰迪";
$t->weight = "3.1";
$t->shoulderHeight = "22";
$t->price = "5000";

// 输出狗类的所有信息
$t->introduce();
?>
</body>
</html>

5.3, Result display:

 6.Network Security Assignment 2

6.1, title:

Write a square class Square: Attributes in the class: length, width Methods in the class: 1. Method to display direction information: display length and width, and display area Test: Generate a direction object s with a length of 6 and a width of 5 , displays length and width, and displays area

6.2, code interpretation

The types of questions here are also consistent with the types of questions above. As long as you understand the first question, it is not a problem to understand the other two.

6.3, Result display

7. Summary

This article is a realization of my own idea, because I want to write code through my commonly used software. Without this function, I can solve it through my own method. Although I was doing the network security course, I suddenly found that Entering the advanced class, I will directly teach PHP object-oriented. Fortunately, I have learned some PHP basics and have a deep understanding of python learning, which is acceptable. The jump is sudden, but I still feel that I have learned a lesson. Programming language is a very important thing for you.

A word a day

The essence of love is not to lead to marriage, but to explore the truest self.

  If my study notes are useful to you, please like and save them. Thank you for your support. Of course, you are also welcome to give me suggestions or supplement the shortcomings in the notes. It will be of great help to my study. Thank you.  

Guess you like

Origin blog.csdn.net/weixin_72543266/article/details/132737528