|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-07-15 14:08 UTC] zeev@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 05:00:01 2025 UTC |
Short: In a class "if ($this->arr[$keyname] != 0);" will allways be false. Long: <? class Auth { var $AuthTblCols = array('login' => 'login', 'passwd' => 'passwd', 'access_lvl' => 0, 'last_login' => 0); //.... snip .... function ColOK($colname, $str) { print_r("<pre>ColOK:"); var_dump($this->AuthTblCols[$colname]);print_r("</pre>"); /* returns string 'access_lvl' (see under) */ if (!empty($this->AuthTblCols[$colname]) && !($this->AuthTblCols[$colname] == 0) /* The Line above will allways evaluate false!!?! at first I had: $this->AuthTblCols[$colname] != 0 But it also evaluates false.*/ ) { print_r("HERE"); return (empty($str)?true:$str); } return false; } function somefunc() { // a func inside the class will call ColOK() if (!$str = $this->ColOK('access_lvl', "somestring I want returned")) echo "Not ok"; //.... snip .... } $auth = new Auth(); $auth->AuthTblCols = array('login' => 'login', 'passwd' => 'passwd', 'access_lvl' => 'access_lvl', 'last_login' => 'last_login'); if (!$auth->A_func_that_will_run_somefunc()) { echo "Invalid login/password"; exit; } ?>