11 May 2011

php variable scope

1) global
<?php
$a = 1;
$b = 2;

function cuba(){
  global $a;
  echo "\$a = $a  \$b = $GLOBALS['b']";
}
?>

2) static
<?php
  function init(){
  static $a;
  $a++
}

No comments:

Post a Comment

Terima kasih