php - php中的字符串内容
问题描述
我想用条件连接多个字符串
我在 ajax 和 php 中做一个加载,我想动态响应,所以我尝试了下面的代码
$newList .= '<ul>';
$newList .= '<li>';
$newList .= '<i class="fa fa-calendar"></i>';
$newList .= $this->Common_model->startend_date_format($getEvent['event_stat'], $getEvent['event_end']);
$newList .= '</li>';
$newList .= '<li>';
$newList .= '<i class="fa fa-map-marked"></i>';
if ($city != "") {
$newList .= '<a href=' . base_url() . 'city/' . $this->Common_model->makeSeoUrl($city) . '>' . ucfirst($city) . '</a>, ' ;
}
if ($state != "") {
$newList .= '<a href="' . base_url() . 'state/' . $this->Common_model->makeSeoUrl($state) . '>' . ucfirst($state) . '</a>,  ';
}
if ($get_country_name != "") {
$newList .= '<a href=' . base_url() . 'country/' . $this->Common_model->makeSeoUrl($get_country_name) . '/' . base64_encode($get_country_id) . '>' . ucfirst($get_country_name) . '</a>';
}
$newList .= '</li>';
$newList .= '<li>';
$newList .= '<i class="fa fa-tags"></i>';
$newList .= '<a href=' . base_url() . 'categories' . '#' . $cat_name_event . '>' . $cat_name_event . '</a>';
$newList .= '</li>';
$newList .= '</ul>';
它显示了类似的东西
但实际结果应该是这样的
解决方案
推荐阅读
- android - 如何使用 FFMPEG 在 android 中的视频上连续加载 GIF?
- android - 不变的违规行为:对象作为 React 子对象无效(发现:带有键 {fontweight, fontsize} 的对象)
- pdf - ps2pdf时gsview 9.27发生了什么
- laravel - 如何从larvel框架模型中的表中获取数据并直接在视图中使用?
- react-native - 在本机反应中添加长按事件
- php - 覆盖 Laravel 5.2 上的 phpunit
- ios - 在 XCode 上需要帮助:线程 1:EXC_BAD_INSTRUCTION (WebView)
- go - 从选择插入时缓冲通道不阻塞的正确方法是什么?在 goroutine 中做这件事是一种反模式吗
- java - java.sql.SQLException: 无法获得连接,池错误 Timeout waiting for idle object 。如何恢复连接
- mysql - 如何获得精确插入行的 auto_increment 主键?