本文整理匯總了PHP中Console::alert方法的典型用法代碼示例。如果您正苦於以下問題:PHP Console::alert方法的具體用法?PHP Console::alert怎麽用?PHP Console::alert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Console
的用法示例。
在下文中一共展示了Console::alert方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setLogsFromData
/**
* Any logs sent in the GET request will be removed from the data property and added through the Console class.
* The returned array will be all original key/value pairs minus logs
*
* @param array $data
* @return array
*/
private function setLogsFromData($data)
{
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
foreach ($data as $key => $value) {
if ($key == 'logs' && is_array($value)) {
foreach ($value as $key => $log) {
if (isset($log['type']) && isset($log['message']) && isset($log['file']) && isset($log['line'])) {
switch ($log['type']) {
case Console::ALERT:
Console::alert($log['message']);
unset($data[$key]);
break;
case Console::LOG:
Console::log($log['message'], $log['file'], $log['line']);
unset($data[$key]);
break;
case Console::ERROR:
Console::logError($log['message'], $log['file'], $log['line']);
unset($data[$key]);
break;
default:
break;
}
}
}
}
}
}
return $data;
}
示例2: testGetAlerts
/**
*
*/
public function testGetAlerts()
{
Console::alert('hello');
$logs = Console::getAlerts();
$this->assertEquals('hello', $logs[0]['message']);
}