Jump to content

-> help


onthespot

Recommended Posts

So I have been looking code to understand it more.

The following came up.

 

 $database->removeActiveUser($this->username);

 

Could anyone point me in the right direction to working out what this means?

I assume the $database is for the include page called database.

 

Thanks

 

Link to comment
Share on other sites

$database is a class object. And removeActiveuser is a method of the class $database or a method in a class $database inherits.

 

The -> operator is like the . (dot) operator in JavaScript, Java, C, etc.. If you know Perl, that operator is the same. ;)

Link to comment
Share on other sites

Beaten but wth,

 

Read a tutorial on Classes, that will tell you all you need to know, and will explain much faster/better than on here.

 

http://www.lmgtfy.com/?q=PHP+Classes+Tutorial

 

Look for a few, they will show you what is going on here.

 

$database is an instantiated class.

removeActiveUser() is a method of that specified class.

This method requires an argument of (im guessing) a username.

The username is stored in the current class you pulled this code from. (authentication class?).

 

-CB-

Link to comment
Share on other sites

It's Object Oriented code.  The '->' is an object-to-member operator.  removeActiveUser() is a method (read: function) of the $database object.  $this->username is the argument passed to that method, and is a data member of whatever object's class code you're currently reading.

Link to comment
Share on other sites

Very grateful for all the responses. It is something I really need to get to grips with.

So the -> is the same as the . in C#? In that case, I understand what it does.

 

The $this is one i have seen often, it there a reason to use the word this?

I'll look on that link thankyou.

Link to comment
Share on other sites

Very grateful for all the responses. It is something I really need to get to grips with.

So the -> is the same as the . in C#? In that case, I understand what it does.

 

The $this is one i have seen often, it there a reason to use the word this?

I'll look on that link thankyou.

 

The following in PHP:

 

$this->someDataMember;

 

Is the same as the following in C#:

 

this.someDataMember;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.