Using this when not in object context in

Source: Internet
Author: User
Tags pconnect



Problem
Using $ this when not in object context in
Solution
Private $ link_id;

Private $ SQL;

Private $ getAll = array ();

Private $ getOne = array ();

Private $ qRes;

Public static function _ init (& $ dsn, $ pconnect = FALSE, $ halt = TRUE ){

If (! Is_array ($ dsn) exit ('error, Dsn not is array ');

$ Dsn ['host'] = (isset ($ dsn ['host'])? $ Dsn ['host']: 'localhost ';

$ Dsn ['login'] = (isset ($ dsn ['login'])? $ Dsn ['login']: 'root ';

$ Dsn ['dbpwd'] = (isset ($ dsn ['dbpwd'])? $ Dsn ['dbpwd']: NULL;

$ Dsn ['db'] = (isset ($ dsn ['db'])? $ Dsn ['db']: 'test ';

$ Dsn ['Char '] = (isset ($ dsn ['Char'])? Str_replace ('-', NULL, $ dsn ['Char ']): 'utf8 ';

If ($ pconnect ){

If (! $ This-> link_id = @ mysql_pconnect ($ dsn ['host'], $ dsn ['login'], $ dsn ['dbpwd']) {

$ Halt & $ this-> getErrorMsg (_ LINE __);

}

} Else {

If (! $ This-> link_id = @ mysql_connect ($ dsn ['host'], $ dsn ['login'], $ dsn ['dbpwd']) {# An error occurred while executing ..

$ Halt & $ this-> getErrorMsg (_ LINE __);

}

}


Copy code


Reference answer
Use self in static function
Reference answer
Use self! In static functions !!!!!!!!!!!!!!!
Reference answer
... I am not using static now. If it is a public function, it still reports an error.
Reference answer
That's not the case.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.