0

I have this showing up on my site. the lang function is showing on the web, but not runned as it should run on the site. The server is running nginx

Q: Why is it doing that, and how can it be prevented?

enter image description here

content of file:

    <?

function lang($line) {

    $ci = & get_instance();
    $languageVariable = explode(" ", $line);
    $outcome = '';
        foreach($languageVariable as $langLine) {
        $outcome .= $ci->lang->line($langLine);

        }
        return $outcome;


}

function langW($string, $var1 = FALSE, $var2 = FALSE, $var3 = FALSE)
{
    return sprintf(lang($string), ($var1 ? $var1 : ''), ($var2 ? $var2 : ''));
}



function langV($line, $var)
{
    $ci = & get_instance();
    return sprintf($ci->lang->line($line), $var);
}
11
  • Make sure you have Apache running or other web server
    – Mihai
    Commented Aug 25, 2015 at 8:42
  • If there is an error, please paste it as text. When you do, also paste it in Google. You're likely not the first one who's got it.
    – GolezTrol
    Commented Aug 25, 2015 at 8:42
  • 2
    <? make this to <?php , it will definately work :) Commented Aug 25, 2015 at 8:44
  • 1
    sorry not related to this question , dude your name @HawasKaPujaari :P Commented Aug 25, 2015 at 8:49
  • 1
    @n01ze Sshhh! Angrezo ko pata chal jayega ;)
    – DirtyBit
    Commented Aug 25, 2015 at 8:50

1 Answer 1

4

Make sure you have:

short_open_tag=On

in php.ini, then restart your nginx server

http://php.net/manual/en/ini.core.php#ini.short-open-tag

If you can't edit php.ini, then you can either replace all your <? to <?php (not the best..) or add the following to the .htaccess file in your document root:

php_value short_open_tag 1

Remember that your hosting could have disabled this option, so it's not 100% guaranteed that the .htaccess way works.

3
  • Just to note (although, this pretty much depends on the person), it's not fully impracticle to use <?php, as you can still use <?, but it will be short for <?php echo. Again, this is a matter of personal preference, but it does speed things up, especilly if you're doing Object Oriented PHP
    – Toza
    Commented Aug 25, 2015 at 8:49
  • <? is not a shorthand for <?php echo; did you mean <?=? Commented Aug 25, 2015 at 8:52
  • I'll correct it.. ASP made me forget of the little things PHP.
    – Toza
    Commented Aug 25, 2015 at 8:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.