2015-05-14 39 views
-1

我在PHP文件的類中寫了各種函數,我想從我的瀏覽器傳遞值來檢查它是否被插入到我的數據庫中。如何通過URL將值傳遞給PHP函數?

示例代碼:

<? 
class Chat { 
var $db; 
    . 
    . 

function Chat() { 
    $this->initialize(); 
} 
function insertMessage($text) { 
    $text = (string) $_GET["message"]; 
     . //insert query 
     . 
    } 
} ?> 

我試着用http://localhost/www/Chat/chat.php/chat.insertMessage?text=%27message%27&[],但我沒有得到任何迴應。

回答

0

取代

$text = (string) $_GET["message"]; 

$text = (string) $_GET["text"]; 
0

像URL爲https //:www.projectlibrarydb.com/chat.php?mesg=hellodear

代碼來訪問它的方法低於

<? 
class Chat { 
var $msg=null; 
var $db; 
    . 
    . 

function Chat() { 

if(isset($_REQUEST['mesg']) 
{ 
    $this->insertMessage($REQUEST['mesg']); 
} 
} 
function insertMessage($text) { 
    var $text =$text; 
     . //insert query 
     . 
    } 
} ?> 
相關問題