Click here to Skip to main content
13,258,055 members (46,836 online)
Rate this:
 
Please Sign up or sign in to vote.
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 2-Nov-17 2:12am
Updated 2-Nov-17 2:34am

1 solution

Rate this: bad
 
good
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.
  Permalink  

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 |
Web04 | 2.8.171114.1 | Last Updated 2 Nov 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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