PHP-在页面顶部发布警报
是否有可能在HTML的特定部分的引导警报中显示源于PHP的错误?它们是example.php文件中的警报,我想在主页上显示这些文件。我尝试在PHP中创建一个函数,但我希望警报像这样运行 主文件功能PHP-在页面顶部发布警报,php,html,Php,Html,是否有可能在HTML的特定部分的引导警报中显示源于PHP的错误?它们是example.php文件中的警报,我想在主页上显示这些文件。我尝试在PHP中创建一个函数,但我希望警报像这样运行 主文件功能 function postAlert($good, $text) { $type = 'danger'; if($good){ $type = 'success'; } echo '<div class="alert alert-'.$type.'
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>
php中的用于连接。当您在警报中使用+
时。改变你的功能如下
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>';
}
函数postAlert($good,$text){
$type=‘危险’;
如果($好){
$type='success';
}
回显“”.$text.“”;
}
我修复了它,但在调用了哪个文件的postAlert
函数中仍然没有区别?我在example2.php脚本中调用了它
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>';
}