$$:
$foo = 'bar';
$bar = 'foobar';
echo $$foo; //This outputs foobar
function bar() {
echo 'Hello world!';
}
function foobar() {
echo 'What a wonderful world!';
}
$foo(); //This outputs Hello world!
$$foo(); //This outputs What a wonderful world!
stdClass:
$person = array();
$person['name'] = 'bob';
$person['age'] = 5;
$string = $person['name'] . ' is ' . $person['age'] . ' years old.';
可以用stdClass写成:
$person = new stdClass();
$person->name = 'bob';
$person->age = 5;
$string = "$person->name is $person->age years old.";
or:
$page = (int) @$_GET['page']
or $page = 1;
只有$_GET['page']的布尔值为true时$page = 1才会被运行,因为or的优先级比=低
and:
<?php $flag and print "Blah" ?>
只有$flag为true时才会打印,跟or类似。
extract函数:
function render_template($template_name, $context)
{
extract($context);
。。。
}
该函数在模板引擎中很有用,如果你调用render_template('index.html', array('foo' => 'bar'))那么在函数内部将有一个$foo变量,它的值为'bar'
先这些了,后面补上!