<?php /****************************************************************** * IMPORTANTE * IMPORTANTE * IMPORTANTE * IMPORTANTE * IMPORTANTE * * SIEMPRE LEE LOS COMENTARIOS - ALWAYS READ THE COMMENTS !!! * *******************************************************************/ include_once "./configs/config.inc.php"; include_once "./modules/statics/counter.php"; unset($visited); session_start(); $statics = new counter(); $conn = $statics->connect(); $visitstoday = $statics->visitstoday(); $visitstotal = $statics->visitstotal(); $statics->increment(); $statics->disconnect($conn); session_register("visited"); $visited = 1; if ($logout == 1) { setcookie("prguser", ""); setcookie("fijado", ""); header("location:index.php"); } if (isset($prguser) and $fijado == 0) { $conn = mysql_connect($server, $user, $password) or die("No se puede conectar a MySQL"); $db = mysql_select_db($database); $result = mysql_query("Select * from user WHERE user = '******' and password = '******';"); $rs = mysql_fetch_assoc($result); if (mysql_num_rows($result) == 1) { setcookie("prguser", $prguser); setcookie("prguser", $prguser);
// try protected here public function __destruct() { global $test_cnt; $test_cnt--; } public static function destroy(&$obj) { unset($obj); } } Show(); $obj1 = new counter(); $obj1->Show(); Show(); $obj2 = new counter(); $obj2->Show(); Show(); counter::destroy($obj1); Show(); // or uncomment this line and it works //counter::destroy($obj2); echo "Done\n"; ?> --EXPECT-- Count: 0 Id: 0 Count: 1 Id: 1 Count: 2 Count: 1
function __construct() { parent::__construct(); $this->count++; }