0

I have a issue, i have the following interface (http://pastebin.com/c11xbdxh) and i have the following class which implements the interface above (http://pastebin.com/m1zGNfSm).

I am using the following autoload function in order to load the classes dynamically:

function autoloadClass($className)
{
      $classParts = explode("\\", $className);
      $fileName = SYSTEM_CORE_PATH . DIRECTORY_SEPARATOR . "classes" . DIRECTORY_SEPARATOR . strtolower(str_replace('_', DIRECTORY_SEPARATOR, end($classParts)) . '.class.php');

      if (is_readable($fileName)) {
          if (SYSTEM_DEBUG) {
               include_once($fileName);
          } else {
               @include_once($fileName);
          }
      }
 }
spl_autoload_register("autoloadClass");

and when i creating a new object class (under the autoloading code) i don't get any error neither any output...

try {
$db = new Core\Infrastructure\MySQL(array('user' => DB_USER, 'pass' => DB_PASS, 'host' => DB_HOST, 'name' => DB_NAME));
} catch (PDOException $pdoE) {
    echo $pdoE->getMessage();
} catch (Exception $e) {
    echo $e->getMessage();
}

echo "<pre>ddd";
$db->runQuery("SELECT * FROM `users`;");
print_r( $db->fetchData());

Thanks for your kind help :)

  • You are trying to evaluate constant to true, which maybe is set to any other value, maybe defined() is better way, because now, you most likely are entering the second case with suppresing errors – Royal Bg Sep 22 '13 at 14:14
  • i use a fallback code which defines it as false if not defined earlier. –  Sep 22 '13 at 14:15

2 Answers2

0

"Don't get any error neither any output" usually means a Fatal or Parse error eaten by error_reporting settings. Check logs. Make sure error_reporting(E_ALL) is set, preferrably in ini file.

Add debug output when $fileName is not readable. This will likely provide an insight.

Leo Nyx
  • 696
  • 3
  • 5
  • i've enabled error_reporting and still don't get any error. The problem began when i add an interface... –  Sep 22 '13 at 15:00
0

Ok i've fixed it, the autoloading only loads the class from the file, it does'nt load the interface.

i've simply added a short code based on class_implements function to the autoload function i wrote.

thanks for all of your help :D