美文网首页
PHP 那些变态的语法 (持续更新)

PHP 那些变态的语法 (持续更新)

作者: JennyGump | 来源:发表于2016-09-29 15:26 被阅读0次

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

$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"));
# 真会会返回上周日的时间

相关文章

网友评论

      本文标题:PHP 那些变态的语法 (持续更新)

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