PHP_EOL:
代表php的換行符,這個(gè)變量會(huì)根據(jù)平臺(tái)而變,在windows下會(huì)是/r/n,在linux下是/n,在mac下是/r;
<?php
$test = 'string from mark';
$username = isset($test) ? $test : 'nobody';
echo $username, PHP_EOL;
switch statement: 避免if語(yǔ)句過(guò)于冗長(zhǎng),提高程序可讀性;
<?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:
- 數(shù)值數(shù)組: array with index;
- 關(guān)聯(lián)數(shù)據(jù): array with key (actually dictionry);
- 多維數(shù)據(jù): contains 1+ array as elements;
<?php
$cars = array("Volvo", "BMW", "Toyota");
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
超級(jí)全局變量
變量名 | 作用 |
---|---|
$GLOBALS | |
$_SERVER | |
$_REQUEST | |
$_POST | |
$_GET | |
$_FILES | |
$_ENV | |
$_COOKIE | |
$_SESSION |