Maison > développement back-end > tutoriel php > Introduction à l'utilisation de la portée des variables php (code)

Introduction à l'utilisation de la portée des variables php (code)

不言
Libérer: 2023-04-04 10:18:01
avant
2254 Les gens l'ont consulté

Cet article vous apporte une introduction à l'utilisation de la portée des variables PHP (code). Il a une certaine valeur de référence. Les amis dans le besoin peuvent s'y référer. J'espère qu'il vous sera utile.

Voici comment diverses variables en PHP sont stockées dans l'implémentation sous-jacente.

Variables :

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

$temp 'temp';

$temp2 $temp;

 

// key

p *executor_globals.symbol_table.arData[7].key.val@4

p *executor_globals.symbol_table.arData[8].key.val@4

 

// value

p *executor_globals.symbol_table.arData[7].val.value.zv.value.str.val@4

p *executor_globals.symbol_table.arData[8].val.value.zv.value.str.val@4

 

 

$temp 'temp';

$temp2 = &$temp;

 

// value

p *executor_globals.symbol_table.arData[7].val.value.zv.value.ref.val.value.str.val@4

p *executor_globals.symbol_table.arData[8].val.value.zv.value.ref.val.value.str.val@4

Copier après la connexion

Méthodes :

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

function test(){

  $temp 'temp';

  static $test 'test';

}

 

// function name

p *executor_globals.function_table.arData[924].key.val@4

 

// function body

p *executor_globals.function_table.arData[924].val.value.func

 

// function temp variable key

p *executor_globals.function_table.arData[924].val.value.func.op_array.vars[0].val@4

 

// function temp variable value

p *executor_globals.function_table.arData[924].val.value.func.op_array.literals[0].value.str.val@4

 

// function static variable key

p *executor_globals.function_table.arData[924].val.value.func.op_array.static_variables.arData[0].key.val@2

 

// function static variable value

p *executor_globals.function_table.arData[924].val.value.func.op_array.static_variables.arData[0].val.value.ref.val.value.str.val@4

Copier après la connexion

Constantes :

1

2

3

4

5

6

7

8

// php

define('AA''aa');

 

// key

p *executor_globals.zend_constants.arData[849].key.val@2

 

// value

p *executor_globals.zend_constants.arData[849].val.value.zv.value.str.val@2

Copier après la connexion

classe :

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

// php

class Apple{

  public $a 'avalue';

  public $a2 'avalue';

  public static $b 'bvalue';

  public static $b2 'bvalue';

  const E = 'evalue';

  const F = 'fvalue';

 

  public function test(){

    $c 'cvalue';

    vr_dump($this->a, $c);

  }

   

  public static function test2(){

    $d 'dvalue';

    vr_dump(self::$b$d);

  }

}

$obj new Apple();

$obj->test();

Apple::test2();

 

// class name 类名保存在class_table的时候的 key 是不区分大小写的,但是类名字本身在 class_entry 中还是有大小写的

p *executor_globals.class_table.arData[153].key.val@5 // 小写

p *executor_globals.class_table.arData[153].val.value.ce.name.val@5 // 保持原样

 

// class body

p *executor_globals.class_table.arData[153].val.value.ce

 

// class protetry key

p *executor_globals.class_table.arData[153].val.value.ce.properties_info.arData[0].key.val@2

 

// class protetry value

p *executor_globals.class_table.arData[153].val.value.ce.default_properties_table.value.str[0].val@6

 

// class static protetry value

p *executor_globals.class_table.arData[153].val.value.ce.default_static_members_table.value.str[0].val@6

 

// class constanct name

p *executor_globals.class_table.arData[153].val.value.ce.constants_table.arData[0].key

 

// class constanct value

p *executor_globals.class_table.arData[153].val.value.ce.constants_table.arData[0].val.value.zv.value.str.val@6

 

// class function name

p *executor_globals.class_table.arData[153].val.value.ce.function_table.arData[0].key.val@4

 

// class function body

p *executor_globals.class_table.arData[153].val.value.ce.function_table.arData[0].val.value.func

 

// class function temp variable

p *executor_globals.class_table.arData[153].val.value.ce.function_table.arData[0].val.value.func.op_array.vars[0].val

Copier après la connexion

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Étiquettes associées:
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal