hi i'm trying to create a site map for my website 
(and i don't want to use any application or ready to use code)

here is how my code works .
first it scans the root directory for files and puts them in a array .
then it loops trough array and get contents of that file and then it'll parse the contents for links (a tags)

scaning the directory 

```
public function scan($directory)
{
        $dir = dir($directory);
        while (($file = $dir->read()) !== false) {
       $type  = ($this->is_directory($directory.$file)) ? 'dir' : 'link' ;
           $this->files[] =  array('address'=>$directory.DIRECTORY_SEPARATOR.$file , 'type'=>$type); 
       }
       sort($this->files);    
       $dir->close();      
}

```

looping trough files and parsing their contents

```
 public function get_links(){
         foreach($this->files as $f )
         {
             if($f['type']  == 'link' )
             { 
                    $contents =  file_get_contents($f['address']);
                    $DOM = new DOMDocument();
                    $DOM->loadHTML($contents);
                    $a = $DOM->getElementsByTagName('a');
                    foreach($a as $link){
                        $this->links[] =  $link->getAttribute('href');
                    }

             }
         }
     }

```

now the problem is when i get the contents of a file in the second pice of code , the php code in that file is not executed . 
so i may get something like :

```
www.site.com/<?php echo $a; ?>.html
or
www.site.com/news.php?id=<?php echo $a; ?>

```

how can i solve this ? 
should i go for curl ? but that wouldn't work with files and it would only works with url address