• 基于php,点亮代码生成技能树


    <?php
    $table = ($_GET['action']);
    /*生成后端*/
    $fileName="core/Motherboard.php";
    $handle=fopen($fileName,"r");//使用打开模式为r
    $contents=fread($handle,filesize($fileName));//读为二进制
    $contents = preg_replace('/{table}/', $table, $contents);//替换后台表名
    //查询表里的列 
    $sql = "select COLUMN_NAME from information_schema.COLUMNS where table_name = :table_name and table_schema = '".$config['dbname']."' ";
    $data = array(
            ':table_name'=>$table
            );
    $data = $db->queryAll($sql,$data);
    foreach ($data as $key=>$value){
        $arrays[] = "
        $".$value['COLUMN_NAME']." = $_REQUEST['".$value['COLUMN_NAME']."'];
        "; 
    }
    $field=implode("",$arrays);
    $contents = preg_replace('/{field}/', $field, $contents);//替换后台列表
    
    foreach ($data as $key=>$value){
        $arr[] = "
        '".$value['COLUMN_NAME']."' => $".$value['COLUMN_NAME'].",
        "; 
    }
    $data=implode("",$arr);
    $contents = preg_replace('/{data}/', $data, $contents);//替换后台列表
    /*生成后端*/
    $ctxtsubmit=$contents;
    $f=fopen("action/".$_GET['action'].".php", "wb");
    //$text=utf8_encode($ctxtsubmit);
    //先用函数utf8_encode将所需写入的数据变成UTF编码格式。
    $text="xEFxBBxBF".$ctxtsubmit;
    //"xEFxBBxBF",这串字符不可缺少,生成的文件将成为UTF-8格式,否则依然是ANSI格式。
    fputs($f, $text);
    //写入。
    fclose($f); 
  • 相关阅读:
    android 启动报错
    android 百度地图
    android LayoutInflater使用
    spring mvc No mapping found for HTTP request with URI [/web/test.do] in DispatcherServlet with name 'spring'
    sql mysql和sqlserver存在就更新,不存在就插入的写法(转)
    jsp include
    json 解析
    css
    Scrapy组件之item
    Scrapy库安装和项目创建
  • 原文地址:https://www.cnblogs.com/hellowzd/p/9698637.html
Copyright © 2020-2023  润新知