Jump to content

class referenced from with another class not working in IE


calast

Recommended Posts

I ran into an interesting problem when doing a customer demo today (worst possible time) that I traced to an IE-specific behavior. I've coded around this but am interested in knowing if others have run into this, and if there's an obvious workaround, because I really liked this code...

 

Assume that there is a class called Facility, stripped down to this:

 

class Facility {

var $id;

var $Latitude;

var $Longitude;

// and some other properties...

function Facility($id) { $this->id = $id; }

function ReadFromDB($rec) {

// read a record from the database, filing in all properties for this object from the specified record

}

function GetLatitude() { return $this->Latitude; }

function GetLongitude() { return $this->Longitude; }

}

 

Note that I just typed this in, and please believe any typos I make here are not in the original code. Now, there is another class called Dispatch, which also has latitude and longitude information, which I wish to copy from the facility.

 

class Dispatch() {

$latitude;

$longitude;

$facility;

// various other properties

function SetLatLon() { // from the facility

$f = new Facility(0);

$f->ReadFromDB($this->facility);

$this->latitude = $f->GetLatitude();

$this->longitude = $f->GetLongitude();

}

}

 

Now this works fine in Firefox - I have not yet tested in Safari and Opera. But in IE, it complains that $f->getlatitude is not defined. Note that the error message has mapped the call to all lower case, which might be OK - but it doesn't work. Note also that it didn't complain about the constructor or the ReadFromDB method - just GetLatitude. So it seems clear that it isn't a problem with finding the class file - require_once('facility.php') - since if it couldn't find that file, it could not have found the other methods either.

 

This behavior is observed on different hosts running different versions of PHP, and I have looked directly at the included class definition to ensure that I didn't have some old version that was missing those methods. Besides which, it works OK in Firefox, just not in IE.

 

Anyone have an idea as to what is going on here? Not a showstopper, since I fixed it by retrieving the info from outside the class, but if this really is an IE limitation, I'd like to not make this mistake again. Thanks for any suggestions.

 

-Ken

 

 

 

 

Link to comment
Share on other sites

First of all, you're using deprecated PHP4 OOP syntax, which is bad already.  Secondly, if you need to ask that question, I don't think you completely understand what PHP is.  PHP is completely server-side, and any processing is browser-independent.  Maybe FF just isn't showing the errors for whatever reason?  Add the following lines to the top of the script:

 

ini_set('display_errors', 1);
error_reporting(E_ALL);

Link to comment
Share on other sites

OK, we'll skip over the vaguely insulting tone, and just take the opportunity to point out that I understand completely where PHP runs. I make my living writing Ajax code. It does not change the fact the problem can only be observed when the browser in use is IE. Also, there is a reason that the code is written to version 4 standards. I have no control over the server environment, and it has to run under PHP 4. When you do this for a living, you work in the environment your employer specifies. Such is life.

Link to comment
Share on other sites

OK, we'll skip over the vaguely insulting tone, and just take the opportunity to point out that I understand completely where PHP runs. I make my living writing Ajax code. It does not change the fact the problem can only be observed when the browser in use is IE. Also, there is a reason that the code is written to version 4 standards. I have no control over the server environment, and it has to run under PHP 4. When you do this for a living, you work in the environment your employer specifies. Such is life.

 

1) I don't think he was really being that insulting, he was probably being serious.

2) Although I still live with my parents (I'm 15), I still program for a (pseudo?)living (if by living you mean clubs, movie theaters, and mall, then yeah), so I very well understand the implications of employers having bad servers. =P  I talk to them and they usually find a way to upgrade.

 

Did you add the code I suggested?  Also, are you actually accessing this page through Ajax or just through normal browsing?  I'd suggest the latter until it's up and running (so all errors can be observed).

Link to comment
Share on other sites

I couldn't care less what you do for a living. Your lack of knowledge about the subject was laughable. So, I laughed.

 

I'll bet that the page IS being access via Ajax, and the disparity functionality from browser to browser has to do with JavaScript and not PHP.

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.