PHP 整理

一、数据类型

  1. integer   ex:$intName1 = 12;
  2. double   ex:$a=100.0235;
  3. boolean  ex:$boolName1 = false;
  4. string    ex:$tringName1 = "hello";

二、集合

  1. array  ex:$array = array(1,2,3);
  2. object ex:$a = new A();

三、流程

  1. if   ex:
    <?php
    $foo = "xxx";
    if($foo == "xxx")
    {
    echo "==";
    }
    else
    {
    echo "!=";
    }
    ?>
  2. while  ex:
    $i=1;
    while($i<=5)
    {
    echo "The number is " . $i . "<br />";
    $i++;
    }
  3. do...while  ex:
    $i=1;
    do
    {
    echo "The number is " . $i . "<br />";
    $i++;
    }
    while($i<=5);
  4. for
    for ($i=1; $i<=5; $i++)
    {
    echo "Hello World!<br />";
    }
  5. foreach
    $arr=array("one", "two", "three");

    foreach ($arr as $value)
    {
    echo "Value: " . $value . "<br />";
    }





 

posted @ 2012-02-10 21:33  木由水  阅读(187)  评论(0编辑  收藏  举报