zoukankan      html  css  js  c++  java
  • php定义变量

    1.引用全局变量

    1

    1 <?php

    2  $var=0;

    3  function test($index)

    4  {

    5      global $var;

    6      $var=$var+1;

    7      echo "The ".$index." number is ".$var."<br>";

    8  }

     test(1);

    10  test(2)

    11 ?>

    2

    1 <?php

    2  $var=0;

    3  function test($index)

    4  {

    5     

    6      $GLOBALS["var"]=$GLOBALS["var"]+1;

    7      echo "The ".$index." number is ".$GLOBALS["var"]."<br>";

    8  }

    9  test(1);

    10  test(2)

    11 ?>

    2.定义常量

    bool define ( string name, mixed value [, bool case_insensitive] )

    name 为常量名,value为常量的值。case_insensitive]为大小写敏感。默认为敏感。例如:

    1 <?php

    2 define("CONSTANT", "Hello world.");

    3 echo CONSTANT; // outputs "Hello world."

    4 echo Constant; // outputs "Constant" and issues a notice.

    原文:

    http://www.cnblogs.com/confach/articles/470492.html

  • 相关阅读:
    BM&EXCRT
    杨丰磊
    poj3613 Cow Relays
    详解KMP算法
    信息学作文
    恐怖的奴隶主(bob)
    玩具(toy)
    杯子 (glass)
    P3916 图的遍历
    《上帝给我一个任务,叫我牵一只蜗牛去散步》
  • 原文地址:https://www.cnblogs.com/mydomain/p/2733085.html
Copyright © 2011-2022 走看看