Click here to Skip to main content
13,768,845 members
Rate this:
Please Sign up or sign in to vote.
See more:
<a href="">Album —</a>[<a href="" target="_blank" title="New Window">^</a>]

i change: $this->db = new DB_con(); 
out with $my_db_connection = new DB_Con; 

and $result = $this->db->query($query); 
out with $result = $my_db_connection->connection->query($query);? 

the first one is in class.user file with a link to database the second line is in login with a link to class.user file

or something else how i fix this?

What I have tried:

i am comfused i dont no how to fix please help
Posted 2-Nov-17 2:12am
Updated 2-Nov-17 2:34am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

For the most part, you use $this-> when you're referring to a class member or member function withing the class. Local variable, within the class, don't have the $this->
So - to use $this-> your symbol must be a member of the class

When you create an instance of a class, like
$item = new someclass(); then you access the members using $item->
Think of it as the external replacement for the internal $this->

Outside of the class, however, $this-> doesn't make sense

See here: PHP 5 Data Types[^] Classes are referred to as data objects.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web01-2016 | 2.8.181116.1 | Last Updated 2 Nov 2017
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100