我有2個班調用另一個類的一個類的內部功能
- 爲DB
- 語言
我想用我的語言的東西在DB 因此它輸出的結果
ex:
class db_control{
var $db_connection, $lang_var;
//create the function for the connection
function db_connect(){
//define some variables
global $db_host, $db_username, $db_password, $db_name, $lang_var;
$this->db_connection = mysql_connect("$db_host","$db_username","$db_password")or die("can't connect to server with these informations");
//checl that the connection is established
if($this->db_connection){
echo $lang_vars->getvar("$langvals[lang_con_est]");
}
但這
$lang_vars->getvar("$langvals[lang_con_est]");
不起作用 我的意思是輸出許多問題 。我肯定我的問題是我正確
PS沒有定義我的變量和類:語言類文件名爲language.php,這部分是DB.MySQL.php
編輯: 這是語言類
class lang_vars{
public static function getvar($variable){
return $variable;
}
}
我想DB類從語言類,爲什麼我用
echo $lang_vars->getvar("$langvals[lang_con_est]");
顯示文本 多數民衆贊成,但它不工作 因爲當我宣佈語文課 $ lang_vars =新lang_vars; 的db_control裏面顯示錯誤意外T_something預期T_Function ,當我沒有外面聲明它 希望我做的事情更清楚了吧
你的意思是php4的語法? 我從來沒有使用PHP4 – SAFAD 2010-09-02 12:23:11
@SAFAD你正在使用'var'關鍵字來聲明類屬性。 [這是PHP4語法](http://php.net/manual/en/oop4.php)。此外,您沒有使用[可見性聲明](http://de.php.net/manual/en/language.oop5.visibility.php)。查看[手冊](http://de.php.net/manual/en/language.oop5.php)和[本教程](http://thinkvitamin.com/dev/getting-started-with-oop -php5 /)和這[簡介](http://stackoverflow.com/questions/2206387/learning-php-class/2206835#2206835) – Gordon 2010-09-02 12:26:37
好吧好吧 也許我還在用舊的東西 我應該替換什麼「var」與? – SAFAD 2010-09-02 12:28:32