ThinPHP第二十八天(F函数和file_put_contents区别|PHP生成PHP文件,Kindeditor编辑器使用方法)

1、F(name,data,path)函数和file_put_contents(file,str)区别

  F函数直接生成<?php ?>格式的php文件了,将data加入到<?php和?>之间中。

  file_put_contents(file,str),将str写入到file中。

  str应该自己设计格式

$str = "<?php
return ".var_export(array_change_key_case($_POST,CASE_UPPER),true).";
?>";

  其中 表示换行,转义字符应该房子双引号内才能被解析。

  var_export($arr,true)将数组转化成为字符串样式。

  array_change_key_case($arr,CASE_UPPER);将数组的键名大写。

2、Kindeditor编辑器使用方法

  第一步:引入文件

  <js file="__PUBLIC__/Js/kind/kindeditor-all-min.js" />

  <js file="__PUBLIC__/Js/kind/lang/zh_CN.js" />

  <cs file="__PUBLIC__/Js/kind/themes/default/default.css" />

  第二步:创建编辑器容体

  <textarea id="mycontent" name="mycontent"></textarea>

  第三步:创建JS代码

KindEditor.ready(function(K){
                //题目富文本框
                window.editor = K.create('#mycontent',{
                    '700px',
                    uploadJson:"{:U(GROUP_NAME.'/Timu/upload')}",
                    allowFileManager : true,//远程管理文件
                    allowImageRemote : false,//远程图片添加
                    formatUploadUrl:false,//不自动替换返回图片url地址 需要url重写支持 隐藏index.php
                });

  注意:Kindeditor可以与Jquery结合使用,结合使用Jquery的选择器。

  另:单独调用上传图片的方式。这里面就结合了JQuery进行使用。用JQuery选择器选择元素。

$('input[add=upload]').live('click',function(){
                   
                    var imgurl = $(this).prev();
                       
                             editor.loadPlugin('image', function() {
                                  editor.plugin.imageDialog({
                                       //imageUrl : $('this').prev('').val(),
                                       clickFn : function(url, title, width, height, border, align) {
                                            imgurl.val(url);
                                            editor.hideDialog();
                                       }
                                  });
                             });
                });

  另外要注意:当使用form.submit()提交时,应该afterBlur: function(){this.sync();}属性,当失去焦点时候同步到textarea中。

2、JQuery中live用法。

  使用Jquery动态生成的元素,不能采用一般选择器方式选中,要使用live方法才能使用,如上面代码所示。

  $('sector').live('action',function(){code.....});

原文地址:https://www.cnblogs.com/huilange/p/3565674.html