dongzhiyi2006 2014-03-31 13:46
浏览 57
已采纳

在nginx中的codeigniter和响应中的php-fpm奇怪的脚本

The setup is: CentOS 6.5 + NGinx + php-fpm running a codeingniter project.

I managed to get it working but I don't understand where is the weird script in the response is originating I expect the result to be clean:

{"auth":true,"success":true,"data":[],"result_count":0}

And not contain the following. Anybody know how to solve this? is it configuration related?

<?


    if ( ! defined('BASEPATH')) exit('No direct script access allowed');


    function remove_http($url = '')
    {
        if ($url == 'http://' OR $url == 'https://')
        {
            return $url;
        }
        $matches = substr($url, 0, 7);
        if ($matches=='http://') 
        {
            $url = substr($url, 7);     
        }
        else
        {
            $matches = substr($url, 0, 8);
            if ($matches=='https://') 
            $url = substr($url, 8);
        }

        return rtrim($url, "/");    


    }


    function resize_img($file,$width,$height=0) {

        /*
         *  general function for resizing images.
         *
         */ 




        $CI =& get_instance();

        $CI->load->library('image_lib');




        $file_name =  $file['file_name'] ;              
        $file_path = "gallery/" . $file_name ;

        $ratio = $file['image_width'] / $file['image_height'] ; ;



        /* Resize the image only if bigger than the 
         * original size . */

        if ($file['image_width'] > $width ) { 

            $cfg2['image_library'] = 'gd2';
            $cfg2['source_image']   = $file_path ;                                                  



            $cfg2['width'] = $width ;


            if ($height==0){

                // auto adjust the height

                $cfg2['maintain_ratio'] = TRUE;
                $cfg2['height'] = $width / $ratio ;             

            }  else $cfg2['height'] = $height ; 


            $CI->image_lib->initialize($cfg2);                                                  
            $CI->image_lib->resize() ; 

        }









    }



    function today() {

        return date("d-m-Y") ; 


    }


    function today_mysql() {

        return date('Y-m-d') ;      

    }



    function current_day () {


        return date ("d") ; 
    }


    function current_month () {

        return date ("m") ; 

    }

    function current_month_year () {

        return date ("m-Y") ;
    }



    function db_2_array($sql_result , $col1 , $col2 , $default = '' ) {

        if ($default) $data = array (0 => $default ) ;

        foreach ($sql_result->result_array() as $row ) {        
            $data [$row[$col1]] = $row[$col2] ;                                 
        }   

        return $data ;      

    }


    function date_2_sql($date) {

        $sql_date = date( 'Y-m-d', strtotime( $date )) ;
        return $sql_date ; 

    }


    function sqldate_2_short($date) {

        return date("d-m",strtotime($date));

    }

    function sqldate_2_med($date) {

        return date("d-m-Y",strtotime($date));

    }


    function sqldate_2_monthyear ( $date ) {

        return date("m-Y",strtotime($date));

    }


    function sqldate_2_long($date) {

        return date("d-m-Y, H:i",strtotime($date));

    }



    function count_days( $a, $b ) 
    { 
        // First we need to break these dates into their constituent parts: 
        $gd_a = getdate( $a ); 
        $gd_b = getdate( $b ); 
        // Now recreate these timestamps, based upon noon on each day 
        // The specific time doesn't matter but it must be the same each day 
        $a_new = mktime( 12, 0, 0, $gd_a['mon'], $gd_a['mday'], $gd_a['year'] ); 
        $b_new = mktime( 12, 0, 0, $gd_b['mon'], $gd_b['mday'], $gd_b['year'] ); 
        // Subtract these two numbers and divide by the number of seconds in a 
        // day. Round the result since crossing over a daylight savings time 
        // barrier will cause this time to be off by an hour or two.

        //return round( abs( $a_new - $b_new ) / 86400 );

        return round( ( $a_new - $b_new ) / 86400 ); 
    }



    function format_text($text) {

        if ($text) { 

            $text = nl2br($text); // add breaks ;       
            $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $text); // set links

        } else $text = ' ' ; 

        return $text ; 


    }   






?>{"auth":true,"success":true,"data":[],"result_count":0}
  • 写回答

1条回答 默认 最新

  • douyu2817 2014-04-01 11:07
    关注

    i think check php shorttag is enabled .. or edit your firstline to .. <?php instead of <?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog