PHP特殊语法积累

下标可以访问字符串中的元素:

$str = "hello world";
$ch  = $str[0]; // $ch 的值是 h

可以使用变量代替类名或函数名

class Animal
{
    public function sayit()
    {
        echo "I am an animal";
    }
}

function curiosity()
{
    // 这儿很变态
    $class = "Animal";
    $anm = new $class;
    $anm->sayit();
}

强大的timetostr函数:

echo date("Y-m-d H:i:s",strtotime("last Sunday"));
# 真会会返回上周日的时间
posted @ 2016-10-28 12:18  liuwensheng  阅读(355)  评论(0编辑  收藏  举报