Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Question about Instantiating an obect

$
0
0

Hey,

 

 I am new to OOP and just started using it. I wrote a simple question that calls a function that does an ehco. But for some reason everytime I call it it echo's the string twice. I'm not sure why. Below is the code i wrote.

 

<?php 


class Train {

var $train="e train";

function train() {
echo "I am in the " .$this->train;	
}

	
}


$train = new Train; 
$train->train();
?>

It echos out the following "I am in the e trainI am in the e train"


Viewing all articles
Browse latest Browse all 13200

Trending Articles