Jump to content

include if variable exists in document


Branden Wagner

Recommended Posts

I dont know if this can be done... or should be done.
ive written a module system, and at the moment you have to go to mod_settings.inc and make each line

$mod_name = "";
$mod_type = ""; // cust,admin,billing,extra,other
$enabled = 1 // 0 or 1

is there a way i can include a file based on whether it contains those variables. all modules are stored in the modules directory.
and i want to include all files which have $mod_type="cust"; in my customer modules list.

ideas?
Link to comment
https://forums.phpfreaks.com/topic/15776-include-if-variable-exists-in-document/
Share on other sites

yes, i want it to include the file

include($module);

but only if in the file i wish to include the variable $mod_type = "cust"  exists else ignore it...

if($mod_type == "cust") # is contain
{ include($module) }

but i figure im going  to do it this way....
[code]
$dir = MODULES ."/". $type ;
if (is_dir($dir))
{
        if ($dh = opendir($dir))
        {
                while (($file = readdir($dh)) !== false)
                {
                        if($file != "." && $file != "..")
                        { include_once($file); }
                }
                closedir($dh);
        }
}
[/code]

so if they dont specify which module they want they get the generic.... but now i will just split up the modules into folders by type and this should fix it..


sooo.. uhh.. just ignore my question i just answered it myself.. i just had to think a bit longer

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.