2018-06-21

作者: markstudio | 来源:发表于2018-06-21 09:00 被阅读0次

PHP_EOL:
代表php的换行符,这个变量会根据平台而变,在windows下会是/r/n,在linux下是/n,在mac下是/r;

<?php 
    $test = 'string from mark';
    $username = isset($test) ? $test : 'nobody';
    echo $username, PHP_EOL;

switch statement: 避免if语句过于冗长,提高程序可读性;

<?php
    $favcolor = 'red';
    switch ($favcolor) {
        case 'red': 
            echo 'Your favorite color is red!';
            break;
        case 'blue':
            echo 'Your favorite color is blue!';
            break;
        case 'green':
            echo 'Your favorite color is green!';
            break;
        default:
            echo 'Your favorite color is neither red, blue, or green!';
    }

array:

  1. 数值数组: array with index;
  2. 关联数据: array with key (actually dictionry);
  3. 多维数据: contains 1+ array as elements;
<?php 
    $cars = array("Volvo", "BMW", "Toyota");
    $age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");

超级全局变量

变量名 作用
$GLOBALS
$_SERVER
$_REQUEST
$_POST
$_GET
$_FILES
$_ENV
$_COOKIE
$_SESSION

相关文章

网友评论

    本文标题:2018-06-21

    本文链接:https://www.haomeiwen.com/subject/wgofyftx.html