Returning a value in constructor function of a class

后端 未结 8 584
情话喂你
情话喂你 2020-11-27 17:04

So far I have a PHP class with the constructor

public function __construct ($identifier = NULL)
{
 // Return me.
if ( $identifier != NULL )
{
           


        
8条回答
  •  -上瘾入骨i
    2020-11-27 17:34

    thanks for all the comments and solutions. here is what i done to fix the problem: (i hope it helps others)

    // Setup the user ( we assume he is a user first. referees, admins are considered users too )
        try {
          $him = new user ($_emailAddress); 
          // check the supplied password 
          $pass_ok = $him->auth($_Password);
    
          // check the activation status 
          $active_ok = $him->makeActive();
    
        } catch (Exception $e_u) { 
          // try the groups database
          try { 
          $him = new group ($_emailAddress);
          // check the supplied password 
          $pass_ok = $him->auth($_Password);
                  //var_dump ($pass_ok);
    
          // check the activation status 
          $active_ok = $him->makeActive();
          } catch (Exception $e_g) {
              // email address was not in any of them !!
              $pass_ok = false; $active_ok = false;
            }
        }
    

提交回复
热议问题