Welcome Guest, Not a member yet? Register   Sign In
Include class in class
#1

[eluser]freshface[/eluser]
Is this possible to do?

Like this:
Code:
<?php

    include 'Snoopy.class.php';

    class Extractor
    {
        function __consruct()
        {
            
        }
        
        
        public function extract($page)
        {
            Snoopy::fetchlinks($page);
            Snoopy::results;
        }
        
    }
        
?>
#2

[eluser]Dam1an[/eluser]
Yeah, although your example is assuming it's in the same directory
If not, just use the defined var APPPATH to build the correct include path
#3

[eluser]freshface[/eluser]
It works

But now i want to do this:
Code:
<?php

    include 'Snoopy.class.php';

    class Extractor
    {

        private $snoopy;
        
        function __consruct()
        {
            $this->snoopy = new Snoopy();
        }
        
        
        public function extract($page)
        {

            $this->snoopy->fetchlinks($page);
            $this->snoopy->results;

        }

But i got an error on $this->snoopy->fetchlinks($page);

Fatal error: Call to a member function fetchlinks() on a non-object in
#4

[eluser]Dam1an[/eluser]
a) Does it work if you create the snoopy object in the extract function and call the copy local to that function
b) What do you get when you do print_r on the snoopy object as soon as it's created, and just before you try to access it in the execute function
#5

[eluser]freshface[/eluser]
If i create the snoopy object inside extract there is no problem.
I just want one object so the object is available over the whole class.

print_r doesn't seem do give any feedback.
#6

[eluser]Dam1an[/eluser]
I spotted it Smile
You have a typo in the constructor, it should be __construct
#7

[eluser]TheFuzzy0ne[/eluser]
I blame Bill Gates...
#8

[eluser]Dam1an[/eluser]
[quote author="TheFuzzy0ne" date="1245544636"]I blame Bill Gates...[/quote]

Care to explain, cause this sounds like it could be good lol
#9

[eluser]freshface[/eluser]
Thanks Dam1an.

This is the thing i am working on: a little class that sniffs a whole site for links inside the same domain.
I still have a logic problem i am working out. care to take a look and help?

zip: http://www.figure8.be/problem.zip
#10

[eluser]Dam1an[/eluser]
Here's a little tip, when asking people for help, it's good to be as specific as possible. The less thinking/time wasting the other person needs to do to figure out whats going on, the better, and more likely they will help lol

So instead of saying you have a logic problem, say which file, function, maybe even line number if it's a mamoth function




Theme © iAndrew 2016 - Forum software by © MyBB