EvilZone

Programming and Scripting => Web Oriented Coding => : gh0st October 27, 2013, 05:52:00 AM

: what im doing wrong?
: gh0st October 27, 2013, 05:52:00 AM
: (php)
<html>
  <head>
    <title>Override!</title>
  </head>
  <body>
    <p>
      <?php
        
class Vehicle {
          public function 
honk() {
            return 
"HONK HONK!";
          }
        }
        
// Add your code below!
        
class Bicycle extends Vehicle{
            public function 
honk(){
                return 
"Beep beep!";
            }
        }
        
        
$bicycle = new Bicycle();
        
$bicycle -> honk();
        
      
?>

    </p>
  </body>
</html>


i need to get an echo of something but the error keeps saying me that I just print : " ....... lol help  :'(

http://www.codecademy.com/courses/web-beginner-en-bH5s3/0/4?curriculum_id=5124ef4c78d510dd89003eb8 (http://www.codecademy.com/courses/web-beginner-en-bH5s3/0/4?curriculum_id=5124ef4c78d510dd89003eb8)

Staff note: Please use the code tags in the future. I have added them this time.
: Re: what im doing wrong?
: Fur October 27, 2013, 06:45:14 AM
Yeah, you're not actually echoing anything.

Line 21 should be:
: (PHP)
echo $bicycle->honk();
: Re: what im doing wrong?
: gh0st October 27, 2013, 06:47:55 AM
(http://i3.kym-cdn.com/photos/images/original/000/234/765/b7e.jpg)
 thanks mate
: Re: what im doing wrong?
: The Alchemist October 27, 2013, 07:01:47 AM
You are returning a value, not printing it out.
So, your code should be like this :
: (php)
$bicycle = new Bicycle();
$output = $bicycle->honk();
echo $output;