ginerjm Posted March 25, 2011 Share Posted March 25, 2011 ok - I lifted some code to help identify the client's browser (damn iphone doesn't like my "select" tag). The code was this class definition and was followed by a couple lines showing how to use it. Here are the two lines: $browser = new Browser ; echo "Using: $Browser->Name $Browser->Version" ; When I include the class and add these two lines to my script all I get is the word "using:' displayed. Is it possible that the writer of this code left something out? I don't know what the syntax of the "x->y" references are, but shouldnt' there be a call to functions within the class? Quote Link to comment https://forums.phpfreaks.com/topic/231721-my-first-class/ Share on other sites More sharing options...
kenrbnsn Posted March 25, 2011 Share Posted March 25, 2011 Since you are using the variable $browser to refer to the class, you need to use <?php echo "Using: $browser->Name $browser->Version" ; ?> If you had named your variable $Browser, the original code would have worked. Ken Quote Link to comment https://forums.phpfreaks.com/topic/231721-my-first-class/#findComment-1192296 Share on other sites More sharing options...
ginerjm Posted March 25, 2011 Author Share Posted March 25, 2011 I just came back online to post that I had solved this - only to see the very first response telling me the same thing. The code was all lifted from a posting I found online, so it wasn't my fault. I did finally see it though after doing some reading on how classes worked. Thanks for the quick response tho! Quote Link to comment https://forums.phpfreaks.com/topic/231721-my-first-class/#findComment-1192298 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.