Jump to content


problems parsing class file

  • Please log in to reply
1 reply to this topic

#1 lvoTusk

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 16 August 2006 - 10:38 AM

OK, so my original problem was I was getting a class not found error after including a file that contains my class definition.
I have narrowed the problem down, so that if I give a full URL to the class' file, it DOES NOT let me use the class, whereas
if I give a relative path to the class' file it WILL let me use the file.

In my server structure (say in localhost/FOLDER1/
I have a file ClassA.php
and also index.php

if in index.php I do
$a = new A;

This works fine, however, if in index.php I do
$a = new A;
I get a "class ClassA not found" error.
BUT I have put an echo statement in my class' file, and in both cases the file is actually being included
as the specific echo is occurring.

any ideas ?


#2 Jenk

  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 16 August 2006 - 01:06 PM

use file system strings, not http:// urls.

Relative path's can also be used.

e.g. if your includes are in "/var/www/includes/" but your document root is "/var/www/docroot/" and you want to use an include file in your main index, you can use:


include '../includes/ClassFile.php';



I prefer to use realpath() to get the absolute path (also to verify the path exists) before including however.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users