0

"<?= site_url('user/profile') ?>" not working on codeigniter 2.1.3

the problem its with

site_url not working on the server

<a href="<?= site_url('user/profile') ?>"><img src="<?php echo base_url()." alt="profile"></a> 

if i do it like this it works

<a href="<?php echo site_url('user/profile') ?>"><img src="<?php echo base_url()."alt="profile"></a> 

on the localhost it works and in another server

maybe the server should have something installed on the php

pedro
  • 447
  • 4
  • 15
  • What do you mean by "not working" exactly, what happens? Try removing the space between `=` and `site_url` though – Pekka Feb 12 '13 at 20:25

4 Answers4

1

It seems your server's php.ini file has not enabled short_open_tags.

Joseph Silber
  • 214,931
  • 59
  • 362
  • 292
1

You must have set short_open_tag to on in php.ini for this to work.

Vasilis Lourdas
  • 1,179
  • 1
  • 16
  • 35
1

The difference is the server configuration. If you are saying that

<a href="<?php echo site_url('user/profile') ?>"><img src="<?php echo base_url()."alt="profile"></a> 

works, it means short_open_tag directive is off in php.ini file, so you must always use the full tag <?php.

For extra info, check this old question. Are PHP short tags acceptable to use?

Community
  • 1
  • 1
Alfabravo
  • 7,493
  • 6
  • 46
  • 82
  • how to configure this – Aravinth E Feb 11 '17 at 07:37
  • @AravinthE That's a different question :) I'd search here in Stack Overflow... I'd find results like [this one](http://stackoverflow.com/questions/12579448/php-short-open-tag-on-not-working) – Alfabravo Feb 13 '17 at 15:22
1

Since you stated that <?php echo works but <?= does not, it looks like Short Tags are disabled in your target environment's php.ini.

Please note that the use of short tags is discouraged