我们如何在自定义 php 文件中获取 joomla 的 configurations.php 变量?

How we will get the joomla's configurations.php variables in custom php file?

我想在我的自定义 php 文件中使用电子邮件设置。我在管理员级别设置的电子邮件设置意味着在全局配置中添加。我在 configuration.php 文件中找到了所有设置和变量。 $smtpuser 和 $smtppass 变量需要在自定义中使用 file.I 我正在使用 joomla 3.2。 请帮助我,如何在我的自定义文件中使用这些配置变量。

您只需创建 JConfig 的对象class。这是代码,将简要说明。 我已经使用了数据库连接变量,您可以使用您的变量代替它。

    require_once ('configuration.php' ); // since this file n configuration file both are at the same location

    $var_cls = new JConfig(); // object of the class

    // variables that you want to use 
    $smtpuser = $var_cls->smtpuser; 
    $smtppass = $var_cls->smtppass;

    // for db connectivity if you want  
    $connlink = mysql_connect($var_cls->host, $var_cls->user, $var_cls->password) or die("Connection Failure to Database");
    mysql_select_db($var_cls->db, $connlink);

 return $db_prefix = $var_cls->dbprefix; // db prefix
$db = JFactory::getDBO();
$prefix = $db->getPrefix();

$db =& JFactory::getDBO();
$prefix = $db->getPrefix();