Jump to content

my first 'class'


ginerjm

Recommended Posts

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?

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.