Re: Accessing config vars in PHP.

From: Date: Tue, 01 Oct 2002 21:07:29 +0000
Subject: Re: Accessing config vars in PHP.
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6059@lists.php.net to get a copy of this message
Michal Zajaczkowski wrote:
Hi Is there a way of accessing assigned config vars in the PHP script? I have done it by $smarty->configs[0][varname], but it's not quite correct, since the "configs" array is a "private" var of the Smarty class. Is there any correct way of doing that? TIA
This was asked forever ago, and I didn't find an answer, so I figured I'd post the code that I used to accomplish just that. It's kinda rough around the edges, but it works, just as long as you don't have any comments in your config file. $conf = "/www/sitename/templates/dostuff.conf"; if ($fp = @fopen($conf, "r")) { while ($line = @fgets($fp, 1024)) { list ($name, $value) = explode ("=", $line); $name = trim($name); $value = trim($value); define($name,$value); } } else { echo "<BR>Could not find config file."; exit; } Easy enough, eh? - Paul Lockaby -- Paul Lockaby paul@dostuff.net http://www.dostuff.net

« previous php.smarty.general (#6059) next »