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 />";
    }





原文地址:https://www.cnblogs.com/muyoushui/p/2346131.html