Jump to content

Recommended Posts

I can not understand why this isn't working, basically it works in one place but not  the other

 

I have this in my main class:

 

class phpLive{
public function loadCore(){
	foreach(glob($this->location."/core/*/*.core.php") as $coreFile){
		$info = (object)pathinfo($coreFile);
		require_once $coreFile;
		$pos = strrpos($info->dirname, "/");
		$coreMedia = substr($info->dirname, $pos + 1);
		$className = str_replace(".core", "", $info->filename);
		$instance = strtolower($className);
		$this->$coreMedia->$instance = new $className();
	}
}
}

 

On the page that I run (index.php), I use this:

 

$_live->example->loadurl();

 

which is in a class that looks like this:

<?php
class ExampleClass extends phpLive{
    public function __construct(){
	$this->loadCore();
}
public function loadurl(){
	$this->net->http->getHttp('http://google.com');
}
}
?>

 

and I get the following error:

Notice: Undefined property: ExampleClass::$net in C:\wamp\www\phpLive\phpLive\plugins\Example\ExampleClass.inc.php on line 7

 

Notice: Trying to get property of non-object in C:\wamp\www\phpLive\phpLive\plugins\Example\ExampleClass.inc.php on line 7

 

Fatal error: Call to a member function getHttp() on a non-object in C:\wamp\www\phpLive\phpLive\plugins\Example\ExampleClass.inc.php on line 7

 

but, when I run this on the main page:

$_live->net->http->getHttp("http://google.com");

 

The code works just fine.

 

Why doesn't the first one work (the above is the actual code, copy and pasted from my editor)?

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.