PHP       WEB       3GL   4GL   5GL      

PHP 1

- .

, :

  1. Users name, login, password;
  2. Users;
  3. ;

. , , .

, , .

:

1<?php
2class Users{
3    public $name;
4    public $login;
5    public $password;
6}
7$user1 = new Users();
8    $user1->name = "Vasya";
9    $user1->login = "vas";
10    $user1->password = 123;
11 
12$user2 = new Users();
13    $user2->name = "Petya";
14    $user2->login = "pet";
15    $user2->password = 321;
16 
17$user3 = new Users();
18    $user3->name = "Vova";
19    $user3->login = "vov";
20    $user3->password = 456;
21?>

. , : , . . ? , .

. , , . , , .

( ) ?

! , .

, - , , , ( - , ) . !

, . , . function takeSpeed().

, , (public, protected, private). , public. , , PHP.

1<?php
2//
3class Car{
4    //
5    public $year = 2003;
6    public $speed;
7    public $model;
8     
9    //
10    public function takeSpeed(){
11      // -
12          echo " = ";
13    }
14}
15//
16$car1 = new Car();
17$car2 = new Car();
18?>

, , : $car1->takeSpeed():

1<?php
2//
3class Car{
4    //
5    public $year = 2003;
6    public $speed;
7    public $model;
8     
9    //
10    public function takeSpeed(){
11        // -
12        echo " = ";
13    }
14}
15//
16$car1 = new Car();
17// c
18$car1->takeSpeed();
19$car2 = new Car();
20?>

, : =.

. , ? , car1, bmw. , , , . speed Car. , () .

, , () .

$this.

: $this->speed.

1<?php
2//
3class Car{
4    //
5    public $year = 2003;
6    public $speed;
7    public $model;
8     
9    //
10    public function takeSpeed(){
11        // ,
12        echo " = ".$this->speed;
13    }
14}
15//
16$car1 = new Car();
17$car1->speed = 210;//
18// c
19$car1->model = "bmw";//
20$car1->takeSpeed();
21 
22$car2 = new Car();
23$car2->speed = 260;//
24// c
25$car2->model = "lexus";//
26?>

: = 210. $car1 (bmw).

, $this.

Car takeSpeed(), paintSpeed(). , paintSpeed() , takeSpeed() paintSpeed(). , , $this. :

1<?php
2//
3class Car{
4    //
5    public $year = 2003;
6    public $speed;
7    public $model;
8     
9    //
10    public function takeSpeed(){
11        // takeSpeed() paintSpeed()
12        $this->paintSpeed();
13    }
14     
15    //
16    function paintSpeed(){
17        // , .
18        echo " = ".$this->speed;
19    }
20}
21//
22$car1 = new Car();
23$car1->speed = 210;//
24// c
25$car1->model = "bmw";//
26$car1->takeSpeed();
27 
28$car2 = new Car();
29$car2->speed = 260;//
30// c
31$car2->model = "lexus";//
32?>

! , $this.

:

  1. Users getInfo();
  2. getInfo() ;
  3. getInfo() ;
1<?php
2class Users{
3    public $name;
4    public $login;
5    public $password;
6     
7    // getInfo()
8    function getInfo(){
9        echo "<p>Name: ".$this->name."<br>";
10        echo "Login: ".$this->login."<br>";
11        echo "Password: ".$this->password."<br>";
12    }
13}
14 
15$user1 = new Users();
16    $user1->name = "Vasya";
17    $user1->login = "vas";
18    $user1->password = 123;
19    // getInfo()
20    $user1->getInfo();
21 
22$user2 = new Users();
23    $user2->name = "Petya";
24    $user2->login = "pet";
25    $user2->password = 321;
26    // getInfo()
27    $user2->getInfo();
28 
29$user3 = new Users();
30    $user3->name = "Vova";
31    $user3->login = "vov";
32    $user3->password = 456;
33    // getInfo()
34    $user3->getInfo();
35?>

, , . , - , 30 . - . ? . . , ?

- , . ?

, . PHP construct (function __construct).

PHP .

, . , :

1<?php
2class Users{
3    public $name;
4    public $login;
5    public $password;
6     
7    //
8    function __construct(){
9        echo "<p> !";
10    }
11     
12    // getInfo()
13    function getInfo(){
14        echo "<p>Name: ".$this->name."<br>";
15        echo "Login: ".$this->login."<br>";
16        echo "Password: ".$this->password."<br>";
17    }
18}
19 
20$user1 = new Users();
21    $user1->name = "Vasya";
22    $user1->login = "vas";
23    $user1->password = 123;
24    // getInfo()
25    $user1->getInfo();
26 
27$user2 = new Users();
28    $user2->name = "Petya";
29    $user2->login = "pet";
30    $user2->password = 321;
31    // getInfo()
32    $user2->getInfo();
33 
34$user3 = new Users();
35    $user3->name = "Vova";
36    $user3->login = "vov";
37    $user3->password = 456;
38    // getInfo()
39    $user3->getInfo();
40?>

. : $user1 = new Users(); Users(). , , - . , . , - , . , . , , (1,2,3). , :

1<?php
2class Users{
3    public $name;
4    public $login;
5    public $password;
6     
7    //
8    function __construct($number){
9        echo "<p> $number!";
10    }
11     
12    // getInfo()
13    function getInfo(){
14        echo "<p>Name: ".$this->name."<br>";
15        echo "Login: ".$this->login."<br>";
16        echo "Password: ".$this->password."<br>";
17    }
18}
19 
20$user1 = new Users(1);
21    $user1->name = "Vasya";
22    $user1->login = "vas";
23    $user1->password = 123;
24    // getInfo()
25    $user1->getInfo();
26 
27$user2 = new Users(2);
28    $user2->name = "Petya";
29    $user2->login = "pet";
30    $user2->password = 321;
31    // getInfo()
32    $user2->getInfo();
33 
34$user3 = new Users(3);
35    $user3->name = "Vova";
36    $user3->login = "vov";
37    $user3->password = 456;
38    // getInfo()
39    $user3->getInfo();
40?>

, , .

, - . .

PHP       WEB       3GL   4GL   5GL         w  

, - , . , .




 10.11.2021 - 12:37: - Personalias -> WHO IS WHO - - _.
10.11.2021 - 12:36: - Conscience -> . ? - _.
10.11.2021 - 12:36: , , - Upbringing, Inlightening, Education -> ... - _.
10.11.2021 - 12:35: - Ecology -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> . - _.
10.11.2021 - 12:34: , , - Upbringing, Inlightening, Education -> , - _.
10.11.2021 - 09:18: - New Technologies -> , 5G- - _.
10.11.2021 - 09:18: - Ecology -> - _.
10.11.2021 - 09:16: - Ecology -> - _.
10.11.2021 - 09:15: , , - Upbringing, Inlightening, Education -> - _.
10.11.2021 - 09:13: , , - Upbringing, Inlightening, Education -> - _.
Bourabai Research -  XXI Bourabai Research Institution