为什么这个不起作用?任何人都知道..我知道有一些小事,但已经浪费了半个多小时。
<?php if(1){ ?>
<?php
echo "
<ul class=\"nav navbar-nav navbar-right\">
<li><a href=\"#\" data-toggle=\"modal\" data-target=\"#loginModal\"><span class=\"glyphicon glyphicon-pencil\"></span> Post</a></li>
</ul>
" ;
}?>
<?php else{ ?>
<?php
echo "
<ul class=\"nav navbar-nav navbar-right\">
<li><a href=\"#\" data-toggle=\"modal\" data-target=\"#loginModal\"><span class=\"glyphicon glyphicon-pencil\"></span> Post</a></li>
</ul>
";
}?>
答案 0 :(得分:0)
这个怎么样?
<?php
if(1){
echo "
<ul class=\"nav navbar-nav navbar-right\">
<li><a href=\"#\" data-toggle=\"modal\" data-target=\"#loginModal\"><span class=\"glyphicon glyphicon-pencil\"></span> Post</a></li>
</ul>
" ;
}
else{
echo "
<ul class=\"nav navbar-nav navbar-right\">
<li><a href=\"#\" data-toggle=\"modal\" data-target=\"#loginModal\"><span class=\"glyphicon glyphicon-pencil\"></span> Post</a></li>
</ul>
";
}
?>
答案 1 :(得分:0)
您正在使用多个冗余的php开始和结束标记。
整个代码块在php中,你只需要一个开头和一个结束
port = 3306
socket = /var/run/mysqld/mysqld.sock
socket = /var/run/mysqld/mysqld.sock
nice = 0
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /dev/shm
bind-address = 0.0.0.0
key_buffer = 128M
max_allowed_packet = 40M
thread_stack = 192K
thread_cache_size = 8
myisam-recover = BACKUP
max_connections = 1000
table_cache = 4096
thread_concurrency = 10
max_heap_table_size = 48M
tmp_table_size = 48M
general_log_file = /var/log/mysql/mysql.log
general_log = 1
slow_query_log = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 2
expire_logs_days = 10
max_binlog_size = 100M
innodb_buffer_pool_size = 4500M
quick
quote-names
max_allowed_packet = 16M
key_buffer = 16M
由于多个php标记,原始代码无效,如果块不正确地结束,那么在其他地方显示为意外标记
见下图