0
我需要有兩個文件。 讓我們把文件控制的第二個:main.php和我們稱之爲輔助文件,一個與我的代碼:second.php從外部文件傳遞參數到一個類
在second.php我:
<?php
class tags{
var $theuser;
var $thebarname;
var $theplace;
var $thetime;
var $themail;
function __construct($theuser,$thebarname,$theplace, $thetime, $themail){
$this->theuser=$theuser;
$this->thebarname=$thebarname;
$this->theplace=$theplace;
$this->thetime=$thetime;
$this->themail=$themail;
}
function give_tags_theuser(){
return $this->theuser;
}
function give_tags_thebarname(){
return $this->thebarname;
}
function give_tags_theplace(){
return $this->theplace;
}
function give_tags_thetime(){
return $this->thetime;
}
function give_tags_themail(){
return $this->themail;
}
}
$tags = new tags("John", "Starbucks", "NY", "4:30", "[email protected]");
$user= $tags->give_tags_theuser();
$barname = $tags->give_tags_thebarname();
$place = $tags->give_tags_theplace();
$time = $tags->give_tags_thetime();
$email = $tags->give_tags_themail();
// with the data before I will send an email using phpmailer, but that's another story
?>
在主。 PHP我需要將變量傳遞給類。這意味着我將刪除:
$tags = new tags("John", "Starbucks", "NY", "4:30", "[email protected]");
從second.php,我會從main.php可以通過這個數據
什麼我有second.php改變,以及如何將main.php是爲了這樣做?
如果我沒有解釋我自己,請告訴我,我仍然是一名學生,我可能還在搞亂詞彙。
非常感謝
非常感謝! – user523129 2011-02-09 17:32:36