我正在設計使用Slim框架的REST API。我正在使用數據庫mySql。我正在用PHP設計這個API。使用REST API從表中提取數據
我想從我的表中獲取有關學生的數據。
我想是這樣的: -
<?php
header('Content-type: application/json');
// Include the Slim library
require 'Slim/Slim.php';
// Instantiate the Slim class
$app = new Slim();
// Create a GET-based route
$app->get('/hello/:name', 'hello');
function hello($name)
{
// here is code to access detail of $name
echo $name
// how can i get detail if i have value of name=:kuntal not name=kuntal
}
// Ready the routes and run the application
$app->run();
?>
我使用這個網址嘗試這一功能: - 192.168.1.101/hello/:kuntal
我需要得到名稱的價值kuntal但在函數中,我得到的名字的價值爲:kuntal所以請告訴我如何刪除名稱前的(冒號)。
是另一種方法來做到這一點。
如果您意識到構建REST API的苗條框架,請給我您的建議。 預先感謝您。