文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Variables

Variables

时间:2008-01-17  来源:xiaoaizhen

$var a simple scalar variable.
$var[28] 29th element of array @var.
$p = \@var now $p is a reference to array @var.
$$p[28] 29th element of array referenced by $p.
Also, $p->[28].
$var[-1] last element of array @var.
$var[$i][$j] $jth element of the $ith element of array @var.
$var{'Feb'} one value from hash (associative array) %var.
$p = \%var now $p is a reference to hash %var.
$$p{'Feb'} a value from hash referenced by $p.
Also, $p->{'Feb'}.
$#var last index of array @var.
@var the entire array; in a scalar context, the number of elements in the array.
@var[3,4,5] a slice of array @var.
@var{'a','b'} a slice of %var; same as ($var{'a'},$var{'b'}).
%var the entire hash; in a scalar context, true if the hash has elements.
$var{'a',1,...} emulates a multidimensional array.
('a'...'z')[4,7,9] a slice of an array literal.
PKG::VAR a variable from a package, e.g., $pkg::var, @pkg::ary.
\OBJECT reference to an object, e.g., \$var, \%hash.
*NAME refers to all objects represented by NAME.
*n1 = *n2 makes n1 an alias for n2.
*n1 = $n2 makes $n1 an alias for $n2.

You can always use a {BLOCK} returning the right type of reference instead of the variable identifier, e.g., ${...}, &{...}. $$p is just a shorthand for ${$p}.

相关阅读 更多 +
排行榜 更多 +
宝宝情商养成宝宝巴士

宝宝情商养成宝宝巴士

休闲益智 下载
燥热手机版

燥热手机版

飞行射击 下载
巨人狙击手安卓版

巨人狙击手安卓版

飞行射击 下载