2018-08-23

2018-08-23  本文已影响0人  深度_1175

今日总结:
数组的传值与传引用(引用是内存共同体,传值需要接受返回值,引用不必)
三维数组(不要在循环里面var_dump,容易被误导,js的each也是)
回调,匿名函数,常量
引入公共静态资源
require的时候,调整路径的时候,ftp工具的复制路径,调试工具的拷贝元素,有用的
代码的重用问题,脱离具体业务逻辑,纯函数实现
自定义debug函数
解析json字符串,为对象
form提交会重写get参数
die不接受函数与整型
调试数据的时候可以直接dump$_gpc
post同时可以get传值(querystring/formdata)

判断==的时候的位置,substr的负数

<font color=#A52A2A size=4 >非常重要,微信jssdk与微信notify请保证可以直接访问到,不要经过入口文件,单一的统一入口文件是行不通的,出现得不到回调或者是签名验证错误,并且微信会为分享链接添加额外参数,也需要注意</font>
jssdk 的接入方法,在微信有demo
将文件放在temp目录下,同时,被引入的文件创建文件似乎有问题,直接可以访问到的文件可以创建文件
在被引入的文件里相对路径有问题,ftp复制路径
不写分毫全部脚本不会执行(编译错误(类似))
$input = file_get_contents("php://input");

<script type="text/javascript">
alert(location.href.split('#')[0]);
</script>
error_log

图片用流来接收(以及xml)

js 属性 变量 不加 引号,包括json


        $(document).ready(function(){

            $("#jk").on("click",function(){

                $.get("http://asd/web/index.php?c=site&a=entry&eid=34&version_id=0&step=1",function(res){

                    data = $.parseJSON(res); 
                    console.log(data);
                    if(data.message.errno == 0){
                        alert(data.message.message);
                    }
                    else{
                        alert(data.message.message);
                    }
                });

            });


        });
        
    </script> 


public function doWebHaomadaoru() {

        //echo __FILE__;die;/www/wwwroot/xyka.sdlrwl.com/addons/lr_txwzjhzs/site.php
        global $_GPC;
        $step = isset($_GPC['step'])?$_GPC['step']:0;
        //echo $step;die;

if($step == 0){

        include $this->template('haomadaoru');
}

if($step == 1){

        $PHPExcel = dirname(__FILE__).'/PHPExcel-1.8/Classes/PHPExcel/IOFactory.php';
        $xlsdir = dirname(__FILE__);
        require_once $PHPExcel;

        
            $inputFileName = $xlsdir.'/phonenumber.xls';
            
            date_default_timezone_set('PRC');
            // 读取excel文件
            try {
            $inputFileType = PHPExcel_IOFactory::identify($inputFileName);
            $objReader = PHPExcel_IOFactory::createReader($inputFileType);
            $objPHPExcel = $objReader->load($inputFileName);
            } catch(Exception $e) {
                echo "请确认模块根目录下存在test.xls文件!<br>";
                die('加载文件发生错误:"'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage());
            }

            // 确定要读取的sheet,什么是sheet,看excel的右下角,真的不懂去百度吧
            $sheet = $objPHPExcel->getSheet(0);
            $highestRow = $sheet->getHighestRow();
            $highestColumn = $sheet->getHighestColumn();

            // 获取一行的数据(从一开始,一是表头)
            for ($row = 2; $row <= $highestRow; $row++){
            // Read a row of data into an array(每次只读一行)
                
            $rowData[] = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE);

            }
            //这里得到的rowData都是一行的数据,得到数据后自行处理,我们这里只打出来看看效果
            //$temparray = [];
            //$temparray = array_merge($temparray,$rowData);
            //$rowData[0][0];

            //$temparray = [];
            //$temparray[] = $rowData;
            

// array(1) { [0]=> array(7) { [0]=> string(14) "问题(必填)" [1]=> string(15) "选项A(必填)" [2]=> string(15) "选项B(必填)" [3]=> string(15) "选项C(必填)" [4]=> string(15) "选项D(必填)" [5]=> string(14) "答案(必填)" [6]=> string(18) "这行请勿删除" } } 
// array(1) { [0]=> array(7) { [0]=> string(18) "哪个肉好吃?" [1]=> string(6) "天鹅" [2]=> string(9) "娃娃鱼" [3]=> string(6) "孔雀" [4]=> string(9) "丹顶鹤" [5]=> string(1) "A" [6]=> NULL } } 
// array(1) { [0]=> array(7) { [0]=> string(18) "哪个好点着?" [1]=> string(6) "酒精" [2]=> string(6) "煤气" [3]=> string(6) "汽油" [4]=> string(6) "柴油" [5]=> string(1) "B" [6]=> NULL } } 

            
            //
            //var_dump($rowData);
            //die;

            /*
            Array
            (
                [0] => Array
                    (
                        [0] => Array
                            (
                                [0] => 17755555556
                            )

                    )

                [1] => Array
                    (
                        [0] => Array
                            (
                                [0] => 17788888887
                            )

                    )

                [2] => Array
                    (
                        [0] => Array
                            (
                                [0] => 17744112233
                            )

                    )

            )
            */

            
            //准备数据
            for ($i=0; $i < count($rowData,COUNT_NORMAL); $i++) { 
                # code...
                $temp[$i]['number'] = $rowData[$i][0][0];
            }

            //echo "<pre>";
            // print_r($temp);
            //die;
            
            for ($i=0; $i < count($temp,COUNT_NORMAL); $i++) { 
                # code...

                $res = pdo_insert("lr_number", $temp[$i], $replace = false);
            }

            

            if (empty($res)) {
                
                message(error(1,"导入号码失败"), '', 'ajax');exit;
            }

            message(error(0,"导入号码成功"), '', 'ajax');exit;
}


        

        
    }




}




上一篇 下一篇

猜你喜欢

热点阅读