I was working my way through addon development using the tutorial in the documentation and modifying it to my needs when I ran into something funny using the include snippet in the tutorial. When you use it on a php file it works just fine, but if you make a chunk file to include javascript, it appends a '1' to the file. A little digging revealed this is because of the way include works in php. I rewrote the include snippet to work the original way if I am including a php file, or to simply return the contents of the file if it is not php
<?php
$isphp = strpos($file,'.php');
if ($isphp !== false) {
//if the file ends in .php we actually want to include the file
$o = include $file;
if (file_exists($file)) {
return $o;
} else {
return "File Not Found: $file";
}
} else {
//if it does not then we just want to return the text of the file
if (file_exists($file)) {
return file_get_contents($file);
} else {
return "FILE NOT FOUND: $file";
}
}