require

How to include a class in PHP [closed]

独自空忆成欢 提交于 2019-12-03 06:42:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I have file index.php , and I want to include file class.twitter.php inside it. How can I do this? Hopefully, when I put the below code in index.php it will work. $t = new twitter(); $t->username = 'user'; $t->password = 'password'; $data = $t->publicTimeline(); 回答1: Your code should be something like require

How to exclude certain requireJS files from uglifying/optimizing

六月ゝ 毕业季﹏ 提交于 2019-12-03 06:42:08
问题 I have a working requirejs project that is using grunt for building and deployment. If using no optimization at all, the build is working without problems and I get one big js file to deploy it on production. The problem I have is, that I have some external frameworks (like angularJS) where I already have a minimized/optimized version of it and don't want to optimize it again. Currently without optimization I include the minified version of this framework via a seperate path config in my

Stream(流)的基本使用

一个人想着一个人 提交于 2019-12-03 06:22:58
本文转载于: 猿2048 网站➵ https://www.mk2048.com/blog/blog.php?id=hj1jbkaaaa 目录 基本使用 可读流 可写流 可读可写混合使用 附源码 流 stream 是一组有序的,有起点和终点的字节数据传输手段,而且有不错的效率。 借助事件和非阻塞I/O库,流模块允许在其可用的时候动态处理,在其不需要的时候释放掉。 流 stream 是一种在Node.js中处理流式数据的抽象接口。 stream 模块提供了以下基础的API,用于构建实现了流接口对象。 流可以是可读、可写、或是可读写的。 基本使用 可读流 在NodeJS中,我们对文件的操作需要依赖核心模块 fs , fs 模块中集成了 createReadStream 可读流。 fs.createReadStream(path, options) 参数如下: path : 读取的文件路径 options : string(指定字符编码) | Object(下面详细介绍) flags : 标识位,默认为 'r' encoding : 字符编码, 默认为null,读取到的值为Buffer fd :文件描述符,默认为 null; mode :权限位,默认为 0o666; autoClose : 读取完后是否自动关闭,默认为true start : 开始读取位置,默认0 end : 结束位置

webpack: import + module.exports in the same module caused error

妖精的绣舞 提交于 2019-12-03 06:20:49
问题 I'm developing a website with webpack. When I have a code like this: import $ from 'jquery'; function foo() {}; module.exports = foo; I got the error Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>' . Turns out that changing import $ from 'jquery' to var $ = require('jquery') don't cause any errors. Why import with module.exports causes this error? Is anything wrong in using require instead? 回答1: You can't mix import and module.exports . In the import

Require file without executing code?

有些话、适合烂在心里 提交于 2019-12-03 05:57:45
Here I have two files: file.rb def method puts "This won't be outputted." end puts "This will be outputted." main.rb require "./file" When running main.rb it will load all the code inside file.rb so I will get "This will be outputted." on the screen. Is it possible to load a file without having it to run the code? Cause I want to load all the methods (in modules and classes too) without having to execute code outside these scopes. Is it possible to load a file without having it to run the code? No, everything in a ruby file is executable code, including class and method definitions (you can

Node.JS load module async

你。 提交于 2019-12-03 05:48:32
I would like to have the ability to load a module that has been changed. I would have to of course unload the module first . Since this is a webserver setup, I am asking if there is a way to load the module in an async fashion, to avoid freezing the webserver for the duration of the read of the updated file. Awhile back Node.JS removed the require.async function. So, on the latest version of Node.JS, what would be the recommended alternative? Should I read the entire file first, and then use the Module library to parse the file contents. (as opposed to the default functionality of taking a

用require和artTemplate做的简单提示框

丶灬走出姿态 提交于 2019-12-03 05:25:11
// require用来加载js文件,artTemplate则用来解析html模板 代码打包了,需要用ngix或其它搭建前端服务器才能正确运行. //主页index.html代码 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <link type="text/css" rel="stylesheet" href="style.css"> </head> <body> <form> 请输入名字:<input> <br> 请输入密码:<input> <br> <input type="submit" value="提交"> </form> <script id="dialog" type="text/html"> <div id="title"><%=title%></div> <div id="content"> <button>取消</button> <button>确定</button> </div> </script> <script type="text/javascript" src="../../lib/require.js" data-main="main.js"></script> </body> </html> //main.js代码 require.config({

webpack4实操笔记

萝らか妹 提交于 2019-12-03 05:08:24
本文转载于: 猿2048 网站➝ https://www.mk2048.com/blog/blog.php?id=h12jccbhaa webpack webpack是模块化管理工具,使用webpack可以对模块进行压缩、预处理、按需打包、按需加载等 四个核心概念 入口entry 入口起点指webpack应该使用哪个模块,来作为构建其内部依赖图的开始。进入入口起点后,webpack会找出有哪些模块和库是入口起点(直接和间接)依赖的。 输出output 告诉 webpack 在哪里输出它所创建的 bundles,以及如何命名这些文件,默认值为 ./dist。整个应用程序结构,都会被编译到你指定的输出路径的文件夹中。 loader loader 让 webpack 能够去处理那些非 JavaScript 文件(webpack 自身只理解 JavaScript)。loader 可以将所有类型的文件转换为 webpack 能够处理的有效模块,然后你就可以利用 webpack 的打包能力,对它们进行处理。 插件plugins 插件的范围包括,从打包优化和压缩,一直到重新定义环境中的变量。插件接口功能极其强大,可以用来处理各种各样的任务。 搭建环境及配置 基本框架 全局安装 #全局安装 ( MAC 需要在 npm 前加 sodu ) npm install webpack -g

file_exists() or is_readable()

此生再无相见时 提交于 2019-12-03 04:26:19
Which one should you use when you want to include a PHP file? if(file_exists($file) require "$file"; or if(is_readable($file) require "$file"; ? file_exists() or is_readable() Which one should you use when you want to include a PHP file? This depends on if you want to know if only a file or a directory exists, or if either is fine, and if you need to check if readable or not. Sometimes you only care the file and/or directory exist, and don't need to read, sometimes you also need to read. Options file_exists() Checks whether a file or directory exists. If you explicitly only want to know if a