[PHP] 利用Slim實作RESTful時,遇到的問題及解法(自我紀錄)

這篇是給我自己紀錄的



問題1:遇到如:
Slim Application Error
The application could not run because of the following error:
Details

Type: ErrorException
Code: 8
Message: Undefined variable: nowDateTime
File: C:\xampp\htdocs\weatherAPI\v1\index.php
Line: 68
Trace

#0 C:\xampp\htdocs\weatherAPI\v1\index.php(68): Slim\Slim::handleErrors(8, 'Undefined varia...', 'C:\\xampp\\htdocs...', 68, Array)
#1 [internal function]: {closure}()
#2 C:\xampp\htdocs\weatherAPI\libs\Slim\Route.php(436): call_user_func_array(Object(Closure), Array)
#3 C:\xampp\htdocs\weatherAPI\libs\Slim\Slim.php(1307): Slim\Route->dispatch()
#4 C:\xampp\htdocs\weatherAPI\libs\Slim\Middleware\Flash.php(85): Slim\Slim->call()
#5 C:\xampp\htdocs\weatherAPI\libs\Slim\Middleware\MethodOverride.php(92): Slim\Middleware\Flash->call()
#6 C:\xampp\htdocs\weatherAPI\libs\Slim\Middleware\PrettyExceptions.php(67): Slim\Middleware\MethodOverride->call()
#7 C:\xampp\htdocs\weatherAPI\libs\Slim\Slim.php(1254): Slim\Middleware\PrettyExceptions->call()
#8 C:\xampp\htdocs\weatherAPI\v1\index.php(135): Slim\Slim->run()
#9 {main}
解決:可能是因為在如get、post功能中引用了外部變數,卻忘的放在use()裡

TAG: php, restful, slim

留言

這個網誌中的熱門文章

[IDE] Eclipse熱鍵大全

[滑鼠] 羅技G402 換微動