0
是否可以在HTML的某個部分的引導警報中顯示源自PHP的錯誤?它們是我想在主頁面上顯示的example.php文件中的警報。我試着PHP創建功能是我想提醒去,像這樣......PHP - 在頁面頂部發布提醒
主文件功能
所包含...
postAlert(true,'This is an error example');
...
我
function postAlert($good, $text) {
$type = 'danger';
if($good){
$type = 'success';
}
echo '<div class="alert alert-'.$type.' alert-dismissable"> <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a><strong> '. $text.' </strong></div>';
}
示例文件嘗試在其中一個示例php文件中調用此函數,但似乎沒有任何事情發生,也沒有發生錯誤。有什麼我做錯了嗎?還是有更好的方法來做到這一點?
<?php include 'navbar.php'; ?>
<!-- Alert goes here -->
<div class="container">
<div class="row">
<?php include 'example1.php' ?>
<?php include 'example2.php' ?>
<?php include 'example3.php' ?>
</div>
</div>
我固定它,但仍然沒有什麼區別 – SillySam
在該文件已被稱爲'postAlert'功能? –
我在example2.php腳本中調用了它 – SillySam