begeiste Posted November 21, 2011 Share Posted November 21, 2011 Hi, I have created a class "friendClass" and tried to echo it. It prints nothing without any errors, not sure what was it going on? Any helps would be appreciated! class friendClass{ //attributes - variable public $name; public $sex; public $title; public $country; //methods - function public function eat(){} public function watch(){} public function drive(){} public function speak(){} } $friend1 = new friendClass; $friend2 = new friendClass; $friend3 = new friendClass; $friend4 = new friendClass; $friend1 -> name = "Bach"; $friend1 -> title = "Muscian"; $friend1 -> sex = "Male"; $friend1 -> country = "Germany"; $friend1 -> eat("Bread"); $friend1 -> speak("German"); $friend1 -> drive("Horse"); $friend1 -> watch("Beethoven"); echo "Name is: ".$friend1->name; Quote Link to comment https://forums.phpfreaks.com/topic/251578-echo-nothing/ Share on other sites More sharing options...
requinix Posted November 21, 2011 Share Posted November 21, 2011 I don't see an opening PHP tag. Did you post your entire code? And are you running PHP 5? Quote Link to comment https://forums.phpfreaks.com/topic/251578-echo-nothing/#findComment-1290207 Share on other sites More sharing options...
begeiste Posted November 21, 2011 Author Share Posted November 21, 2011 Yes. I have opening and closing php tag. Quote Link to comment https://forums.phpfreaks.com/topic/251578-echo-nothing/#findComment-1290214 Share on other sites More sharing options...
PFMaBiSmAd Posted November 22, 2011 Share Posted November 22, 2011 Your code outputs - Name is: Bach If you didn't get anything, either your actual code contains a php error, your opening php tag isn't a full <?php tag, php isn't installed and running on your server, or you didn't browse to the URL of your page in your browser. What does a 'view source' of the page in your browser show? What URL did you browse to (it should be something like http://localhost/your_file.php on your local development system)? Quote Link to comment https://forums.phpfreaks.com/topic/251578-echo-nothing/#findComment-1290378 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.