"<?= site_url('user/profile') ?>"
未在代码点火器2.1.3 上工作
问题出在
site_url在服务器上不工作
<a href="<?= site_url('user/profile') ?>"><img src="<?php echo base_url()." alt="profile"></a>
如果我这样做,它可以
<a href="<?php echo site_url('user/profile') ?>"><img src="<?php echo base_url()."alt="profile"></a>
在本地主机上工作,在另一个服务器中工作
也许服务器应该在php 上安装一些东西
您必须在php.ini中将short_open_tag
设置为on
才能工作。
由于您声明<?php echo
有效,但<?=
无效,因此目标环境的php.ini中似乎禁用了短标签。
请注意,不鼓励使用短标签。
服务器的php.ini
文件似乎没有启用short_open_tag
s。
区别在于服务器配置。如果你说
<a href="<?php echo site_url('user/profile') ?>"><img src="<?php echo base_url()."alt="profile"></a>
有效,这意味着short_open_tag
指令在php.ini
文件中处于关闭状态,因此必须始终使用完整标记<?php
。
如需更多信息,请查看此旧问题。PHP短标签可以使用吗?