Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-27-2002, 12:01 AM   PM User | #1
Phip
Registered User

 
Join Date: Jun 2002
Location: Arizona
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
Phip is an unknown quantity at this point
->

what is " -> " ?
Phip is offline   Reply With Quote
Old 07-27-2002, 01:26 AM   PM User | #2
gorilla1
Regular Coder

 
Join Date: Jun 2002
Posts: 544
Thanks: 0
Thanked 0 Times in 0 Posts
gorilla1 is an unknown quantity at this point
As in object, property relationship?

G
gorilla1 is offline   Reply With Quote
Old 07-27-2002, 01:29 AM   PM User | #3
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,224
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
That's easy. It's an arrow.


Ok ok. That particular arrow in PHP is a way to refer to a method or variable of an object. An object such as a class is a good example:

PHP Code:
<?php

class HelloWorld {

    var 
$hello;

    function 
HelloWorld(){
        
$this->hello "Hello PHP newbie";
    }
    
    function 
say_hello(){
        return 
$this->hello;
    }
}

$my_class = new HelloWorld;
echo 
$my_class->say_hello();


?>
That is just a simple example of creating a class and putting a function in there that returns a string. To refer to the function within that class we first create an instance of it

$my_class = new HelloWord;

then to access the function within it we use the arrow

$my_class->function_name();
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Old 07-27-2002, 03:14 AM   PM User | #4
Phip
Registered User

 
Join Date: Jun 2002
Location: Arizona
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
Phip is an unknown quantity at this point
aahhh ok.. cool thanks
Phip is offline   Reply With Quote
Old 07-27-2002, 03:20 AM   PM User | #5
Phip
Registered User

 
Join Date: Jun 2002
Location: Arizona
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
Phip is an unknown quantity at this point
what a second...

sense when did you need var for a variable?

what on earth is a class? i can't find it on php.net

new? what is new?
Phip is offline   Reply With Quote
Old 07-27-2002, 03:38 AM   PM User | #6
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,224
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
PHP has the capability of doing object oriented programming. A class is simply a way to package up functions to perfom certain tasks. This class is considered an object. When you want to use that object you have to create an instance of it. In object oriented programming this is called object instantiation. The new keyword is used to create an instance of an object like so:

$my_class = new HelloWorld;

This creates an instance of the object class HelloWorld and assigned to the variable $my_class. That variable acts as a reference and holds the object you just created.

Here is a decent tutorial that goes into in more depth.

http://www.zend.com/zend/tut/class-intro.php

It is a very useful feature of PHP.

Here is some more about object oriented programming on php.net:

http://www.php.net/manual/en/language.oop.php
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Old 07-27-2002, 08:30 AM   PM User | #7
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,224
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
Quote:
Originally posted by Phip
what a second...

sense when did you need var for a variable?

since I put it inside the class. Variables and functions inside a class are referred to as member variables and member functions. This mean that they are a member of that object. The object being the class.
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:53 PM.


Advertisement
Log in to turn off these ads.