Help understanding/debugging the following script:

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all.

If you look at the code below, the return() does not produce any output.
No errors were displayed on screen before I added 'error_reporting(E_ALL);'.
(Error message: Notice: Undefined variable: this in /oop/test1/index.php on
line 35, commented on below)
Trying to echo/print ordinary text or variables works fine.

I have some experience coding PHP scripts, but are new on how-to use/write
OOP scripts. (Sample found at: http://www.purephotoshop.com/view.php?id=71)

Here's the Code:
<?php
error_reporting(E_ALL);
class Bike
{
    var $num_speeds, $speed;
    var $rotation;
    var $running = FALSE; // You can set default values for properties,
these values must be constant
    // Change speed method
    function change_speed( $increment = TRUE )
    {
        // ...
    }
    // Pedal and brake methods
    function pedal()
    {
         // ...
    }
    function brake()
    {
         // ...
    }
    // Turn method
    function turn( $angle )
    {
        // ...
    }
}
// Inside the change_speed() method
if( !$this->running ) // This is line 35
{
     return;
}

if( $increment && $this->speed != $this->num_speeds )
{
    $this->speed++;
    return;
}

if( $this->speed != 1 )
{
    $this->speed--;
}
?>

I will be thankful for any help/hints that leads to a solution. If anymore
info are needed, please let me know.


Regards,
Martin

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux