jordanwb Posted January 3, 2008 Share Posted January 3, 2008 I have the class called "date_sys" and it is saved in the file date.php Now I have the file called session.php which includes date.php (they are the in the same directory). date_sys class: <?php class date_sys { static function breakdown_int_timestamp ($timestamp) { $datestamp[0] = substr ($timestamp, 0, 4); $datestamp[1] = substr ($timestamp, 4, 2); $datestamp[2] = substr ($timestamp, 6, 2); $datestamp[3] = substr ($timestamp, 8, 2); $datestamp[4] = substr ($timestamp, 10, 2); $datestamp[5] = substr ($timestamp, 12, 2); return $datestamp; } static function month_from_int ($int) { $int = (int) $int; $months = array ("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); return $months[$int]; } } ?> Now in the session.php file right after I include the file I go: <?php include "date.php"; die(date_sys::month_from_int (4)); ?> And I'm getting: Fatal error: Class 'date_sys' not found in D:\xampp\htdocs\scm\core\session.php on line 12 [Edit] Here's something interesting. The errors occurs on my computer (Windows XP) but not on my Server (Ubuntu Server 7.10). Perhaps something in the php.ini file? Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/ Share on other sites More sharing options...
revraz Posted January 3, 2008 Share Posted January 3, 2008 I believe include is a function. include ("date.php"); Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/#findComment-429301 Share on other sites More sharing options...
jordanwb Posted January 3, 2008 Author Share Posted January 3, 2008 ^ Technically it is but PHP.net refers to it as a "language construct" (whatever that means) so I don't need the brackets. Same for print, echo, require and a few others. Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/#findComment-429302 Share on other sites More sharing options...
revraz Posted January 3, 2008 Share Posted January 3, 2008 You can check the include path in your php.ini and see if something other than / is in there. Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/#findComment-429303 Share on other sites More sharing options...
jordanwb Posted January 3, 2008 Author Share Posted January 3, 2008 I found this in the php.ini file: ;;;;;;;;;;;;;;;;;;;;;;;;; ; Paths and Directories ; ;;;;;;;;;;;;;;;;;;;;;;;;; ; UNIX: "/path1:/path2" ;include_path = ".:/php/includes" ; ; Windows: "\path1;\path2" include_path = ".:\xampp\php\pear\" Is this what you're referring to? Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/#findComment-429306 Share on other sites More sharing options...
revraz Posted January 3, 2008 Share Posted January 3, 2008 Yep, look at your windows include path. Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/#findComment-429312 Share on other sites More sharing options...
jordanwb Posted January 3, 2008 Author Share Posted January 3, 2008 ;;;;;;;;;;;;;;;;;;;;;;;;; ; Paths and Directories ; ;;;;;;;;;;;;;;;;;;;;;;;;; ; UNIX: "/path1:/path2" ;include_path = ".:/php/includes" ; ; Windows: "\path1;\path2" include_path = "/" <- Is that correct? But what's weird is that session.php includes other files. (sql.php, cookie.php plus others) and it's just fine. Why does iit not like my date_sys class? Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/#findComment-429314 Share on other sites More sharing options...
PFMaBiSmAd Posted January 3, 2008 Share Posted January 3, 2008 Are you browsing to session.php directly or are you including it into some main file? Also, what versions of php are you using. The posted code works on php5. Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/#findComment-429316 Share on other sites More sharing options...
jordanwb Posted January 3, 2008 Author Share Posted January 3, 2008 index.php includes core/session.php. session.php in turn includes sql.php, cookie.php, date.php and some others. I'm using PHP 5.2.4 on Windows and 5.2.3 on Ubuntu. Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/#findComment-429319 Share on other sites More sharing options...
revraz Posted January 3, 2008 Share Posted January 3, 2008 Try using an absolute include path just to make sure. Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/#findComment-429325 Share on other sites More sharing options...
jordanwb Posted January 3, 2008 Author Share Posted January 3, 2008 I don't think the path is the issue because all my other includes work and they are in the same directory. Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/#findComment-429327 Share on other sites More sharing options...
PFMaBiSmAd Posted January 3, 2008 Share Posted January 3, 2008 Check your web server log for errors to find out what is really happening. The include_path is probably at fault. Why other include files work (perhaps they are working because they are getting included elsewhere) is any bodies guess. Files for including are first looked for in each include_path entry relative to the current working directory, and then in the directory of current script. E.g. if your include_path is libraries, current working directory is /www/, you included include/a.php and there is include "b.php" in that file, b.php is first looked in /www/libraries/ and then in /www/include/. If filename begins with ./ or ../, it is looked only in the current working directory. Based on that, perhaps you have more than one date.php file and the wrong one is getting found due to the include_path searches and the CWD. Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/#findComment-429370 Share on other sites More sharing options...
jordanwb Posted January 3, 2008 Author Share Posted January 3, 2008 The theory about the double date.php is possible but the question that still remains is why it's fine in linux but not in Windows. Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/#findComment-429382 Share on other sites More sharing options...
trq Posted January 3, 2008 Share Posted January 3, 2008 why it's fine in linux but not in Windows Probably because your windows include_path is foobar'd. Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/#findComment-429392 Share on other sites More sharing options...
PFMaBiSmAd Posted January 3, 2008 Share Posted January 3, 2008 foobar'd Is that a programming specific term or a general technical term? Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/#findComment-429418 Share on other sites More sharing options...
trq Posted January 3, 2008 Share Posted January 3, 2008 General technical :-) Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/#findComment-429429 Share on other sites More sharing options...
jordanwb Posted January 3, 2008 Author Share Posted January 3, 2008 Probably because your windows include_path is foobar'd. Lol, I tried reinstalling XAMPP but that didn't work. As long as it works on my server is fine with me. Quote Link to comment https://forums.phpfreaks.com/topic/84303-cannot-find-class-that-was-just-included/#findComment-429482 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.