TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-19-2008, 02:15 PM   #1 (permalink)
The Wanderer
 
frosty's Avatar
 
Join Date: Aug 2008
Location: texas
Posts: 13
Thanks: 3
frosty is on a distinguished road
Default Just a quick question....

Hi, for those of you that have checked my introduction post, you will know that I am an Art Director that just knows a bit of programming...

While I might know some I do not speak the programmers terms/language...is there a good reference that anyone can point me to where I can get terms in regular English...

For example:

I know when I might need to do something like
PHP Code:
$this -> and_stuff_here
But I have no idea what "$this" actually is called or why I really need it, but I know I need to use it when I use it...(did that make any sense at all)

Thanks.

***EDIT***

NM I found the glossary…this may answer a lot of my questions…

Thanks
frosty is offline  
Reply With Quote
Old 08-19-2008, 06:23 PM   #2 (permalink)
The Wanderer
 
adamsargant's Avatar
 
Join Date: Aug 2008
Location: Haworth, West Yorkshire
Posts: 5
Thanks: 2
adamsargant is on a distinguished road
Default

"$this" is a pseudo variable used within a class to refer to the class itself. Obviously, since the object hasn't been instantiated yet, we can't use it within the class.

say I have an object $foo

$foo=new myclass();

and a property $bar, I can now call that property

$foo->bar

BUT, within the class code, I don't know I'm going to call the object "$foo", so "$this" is used as a generic reference to the object

I'm just getting my head round classes myself, so I hope that helps

Adam
adamsargant is offline  
Reply With Quote
Old 08-19-2008, 07:16 PM   #3 (permalink)
The Wanderer
 
frosty's Avatar
 
Join Date: Aug 2008
Location: texas
Posts: 13
Thanks: 3
frosty is on a distinguished road
Default

Adam,

Thanks for the reply...$this was not in the Glossary.

So it makes better sense now.

Like I said, I know when, but not the whys or what fors of most of this...haha

So now how do I close this Thread?
frosty is offline  
Reply With Quote
Old 08-19-2008, 08:32 PM   #4 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

It might also be worth to notice that $this is a reserved keyword and cannot be overridden when called inside a method.

$this is only available when a method is called from an intialized object, and not staticlly calls, eg. this wouldn't work:

PHP Code:
<?php
    
class TalkPHP
    
{
        protected 
$name;


        public static function 
who($name)
        {
            
$this->name $name;
        }
    }

    
TalkPHP::who('Kalle');
?>
Hope this helps you abit further ;)
__________________
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
The Following User Says Thank You to Kalle For This Useful Post:
frosty (08-19-2008)
Old 08-19-2008, 09:05 PM   #5 (permalink)
The Wanderer
 
frosty's Avatar
 
Join Date: Aug 2008
Location: texas
Posts: 13
Thanks: 3
frosty is on a distinguished road
Default

Yes it does! Thank you!
frosty is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:13 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design