Click here to Skip to main content
15,885,719 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<a href="https://postimg.org/gallery/39s2qs54c/">Album — Postimage.org</a>[<a href="https://postimg.org/gallery/39s2qs54c/" 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
Updated 2-Nov-17 1:34am

1 solution

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900