[英]How we will get the joomla's configurations.php variables in custom php file?
I want to use the email settings in my custom php file. 我想在我的自定义php文件中使用电子邮件设置。 Email settings i am setting in Admin level means added in Global configuration.
我在管理员级别设置的电子邮件设置意味着已在全局配置中添加。 I found the all setting and variables in configuration.php file.
我在configuration.php文件中找到了所有设置和变量。 $smtpuser and $smtppass variables need to use in custom file.I am using joomla 3.2.
$ smtpuser和$ smtppass变量需要在自定义文件中使用。我使用的是joomla 3.2。 Please help me, How i can use these configuration variables in my custom file.
请帮助我,如何在自定义文件中使用这些配置变量。
You just need to create the object of the JConfig class . 您只需要创建JConfig类的对象 。 Here is the code, that will explain briefly.
这是代码,将简要说明。 I've used db connection variables, you can use your variables instead of that.
我使用了数据库连接变量,您可以使用变量代替它。
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();
OR 要么
$db =& JFactory::getDBO();
$prefix = $db->getPrefix();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.