iarp Posted April 21, 2008 Share Posted April 21, 2008 I've been taking a look at the coding for Wordpress and PHPBB to see if i could get any ideas, or grasp any concepts from them on how to do things with the website i'm working on. On both pieces of coding i see alot of -> but don't get exactly how they work Is it like: function taxes(cost, taxRate) { $answer = etc...etc } $data -> taxes($baseCost, 1.13); ? Quote Link to comment Share on other sites More sharing options...
Fadion Posted April 21, 2008 Share Posted April 21, 2008 Take a look at the manual and ull be enlighted. Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Share Posted April 21, 2008 isn't a maths function, e.g greater than and less than Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 It's for calling a method or getting a property from an object. Quote Link to comment Share on other sites More sharing options...
JustinK101 Posted April 21, 2008 Share Posted April 21, 2008 isarp: It references a value or method inside of a class. If you have never played with object oriented programming, I would not worry about trying to understand it. Object oriented programming is much more complex and confusing. Quote Link to comment Share on other sites More sharing options...
atravotum Posted April 21, 2008 Share Posted April 21, 2008 To further that point say you had a class named dog. You could code functions within dog like say bark. So if you wanted to call bark you would use that sign example class Dog { public function bark() { echo "Roof!"; } } //Then to call it you would say $dog -> bark(); This would echo "Roof!"; Quote Link to comment Share on other sites More sharing options...
iarp Posted April 21, 2008 Author Share Posted April 21, 2008 To further that point say you had a class named dog. You could code functions within dog like say bark. So if you wanted to call bark you would use that sign example class Dog { public function bark() { echo "Roof!"; } } //Then to call it you would say $dog -> bark(); This would echo "Roof!"; Makes sense, thank you. That first link to the manual just confused the crap outta me 0.o Quote Link to comment Share on other sites More sharing options...
JustinK101 Posted April 21, 2008 Share Posted April 21, 2008 Correction: Actually atravotum: The code should be: class Dog { public function bark() { echo "Roof!"; } } $dog = new Dog(); $dog->bark(); Quote Link to comment Share on other sites More sharing options...
atravotum Posted April 21, 2008 Share Posted April 21, 2008 I actually read through it to compile the example for you. I have used it in c++ before for pointers i think but that was while ago. The cool thing about classes is you can create new ones on the fly. So if you were making like a pet program to train them you could copy the dog class on the fly and assign it an instance so it can hold variables like health, and weight, and be separate from the other instances of the dog classes. Thats the cool thing about oop (object orientated programming). Quote Link to comment Share on other sites More sharing options...
atravotum Posted April 21, 2008 Share Posted April 21, 2008 lol sorry, i was assuming that was a given Quote Link to comment Share on other sites More sharing options...
iarp Posted April 21, 2008 Author Share Posted April 21, 2008 My next semester is Java OOP so hopefully all that will make alot more sense, but my first guess saying it called functions was correct. Quote Link to comment Share on other sites More sharing options...
atravotum Posted April 21, 2008 Share Posted April 21, 2008 Well yes it can, but it can assign values to variables within classes as well. Consider it sorta like " 's ". So dog -> bark() would be like saying dog's bark function. Or dog -> health = 20; Would be like saying Dog's health equals 20. So it is really just to access code more or less within an object or in this case a class. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.