PHP用法

php语言介绍









';
    echo $a;
    echo $b;
    
    //单引号
    echo '$a+$b';
    //双引号
    echo "$a+$b";
?>






php语法的流程控制代码












";
      $i++;
      }

      
//-----------------第2种循环结构do...while 语句--------------  
      $i=0;
        do
          {
          $i++;
          echo "The number is " . $i . "
"; } while ($i<5); //-----------------第3种循环结构for 语句-------------- for ($i=1; $i<=5; $i++) { echo "循环到:"$i; } ?>

php中的数组

';
        
    }
    
    
    //输出数组name2
    echo $name2[1] . " and " . $name2[2] . " are ". $name2[0] . "'s neighbors";
    
    //输出数组name2
    foreach ($name2 as $value)
    {
      echo "Value: " . $value . "
"; } //输出数组ages foreach($ages as $key=>$value){ echo "key:$key,value:$value"; } //遍历数组ages for($i=0;$i'; } ?>

php函数

";
  }

    echo "My name is ";
    writeMyName("David");
    
    echo "My name is ";
    writeMyName("Mike");
    
    echo "My name is ";
    writeMyName("John");


?>

你可能感兴趣的:(PHP用法)