Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Fatal error: Call to undefined function: gear_up()
Old 09-28-2007, 05:31 PM Fatal error: Call to undefined function: gear_up()
Skilled Talker

Posts: 60
Name: Nick Martin
Trades: 0
Hey Everyone!

So I am fairly versed with PHP applications but I am rather new to OOP with PHP. I am getting the following error: Fatal error: Fatal error: Call to undefined function: gear_up()

Sure this is just some sticky syntax. Here's my object code:

PHP Code:
 
include ("class.bike.php");
 
$bike = new Bike();
$this->gear gear_up();
$this->color change_color("Blue");
$this->cadence speed_up();
echo 
$bike->cadence "<br>";
echo 
$bike->gear "<br>";
echo 
$bike->color
I'm guessing the problem must lie within my class constructor which looks like this:
PHP Code:
class Bike
{
 var 
$cadence 0;
 var 
$gear 1;
 var 
$color "Red";
 
 function 
Bike() {
 }
function 
slow_down(){
 if (
$this->cadence 0){
 
 
$this->cadence--;
 
 }
else{
echo (
"You are already stopped");
}
 }
 
function 
speed_up(){
 
$this->cadence++;
}
function 
gear_up(){
 
$this->gear++;
}
function 
gear_down(){
 
$this->gear--;
 
}
function 
change_color($new_color){
 
$this->color $new_color;
 }
 

What am I forgetting?

Thanks a lot!

-Nick
SpudNik is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-28-2007, 09:14 PM Re: Fatal error: Call to undefined function: gear_up()
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Your trying to call a member function of an object but not specifying the object. The method gear_up() belongs to the instance of the Bike class, bike. You should call it like this bike->gear_up(). the -> operator is similar to the dot operator in c++ and java.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 10-01-2007, 11:56 AM Re: Fatal error: Call to undefined function: gear_up()
Skilled Talker

Posts: 60
Name: Nick Martin
Trades: 0
Well... Duh


I was treating is as if I was trying to return a varible rather than run a method. Thanks for the help.

-Nick
SpudNik is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Fatal error: Call to undefined function: gear_up()
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17757 seconds with 12 queries