require

What is the proper way to extend a class in another file?

夙愿已清 提交于 2019-12-10 12:52:44
问题 This is what I have in foo.php class Foo { public $foo = NULL; public $foo2 = NULL; public function setFoo ($foo, $foo2) { $this->foo = $foo; $this->foo2 = $foo2' } } This is what I have in foo3.php class Foo3 extends Foo { public $foo3 = NULL; public function setFoo3 ($foo3) { $this->foo = $foo3; } } This is how I require it in my third file run.php: require_once "foo.php"; require_once "foo3.php"; $foo = new Foo(); $foo->setFoo3("hello"); I get this error: Fatal error: Call to undefined

TypeScript 模块

岁酱吖の 提交于 2019-12-10 12:25:48
  关于术语的一点说明: 请务必注意一点,TypeScript 1.5里术语名已经发生了变化。 “内部模块”现在称做“命名空间”。 “外部模块”现在则简称为“模块”,这是为了与 ECMAScript 2015 里的术语保持一致,(也就是说 module X { 相当于现在推荐的写法 namespace X { )。   介绍   从ECMAScript 2015开始,JavaScript引入了模块的概念。TypeScript也沿用这个概念。   模块在其自身的作用域里执行,而不是在全局作用域里;这意味着定义在一个模块里的变量,函数,类等等在模块外是不可见的,除非你明确地使用 export 命令 导出它们。 相反,如果想使用其它模块导出的变量、函数、类、接口等,则必须要导入它们,可以使用 import 命令 。   模块是自声明的;两个模块之间的关系是通过在文件级别上使用import和export建立的。   在模块中,模块使用模块加载器去导入其它的模块。 在运行时,模块加载器的作用是在执行此模块代码前去查找并执行这个模块的所有依赖。 大家最熟知的JavaScript模块加载器是服务于Node.js的 CommonJS 和服务于Web应用的 Require.js 。   TypeScript与ECMAScript 2015一样,任何包含顶级 import 或者 export

How to include html partials with webpack (version 2) with the html-loader?

∥☆過路亽.° 提交于 2019-12-10 10:12:13
问题 I am working hard to include a simple footer.html, as an html partial) via html-loader . I am using webpack version 2. I failed trying to use ${require('**./footer.html**')} and ${require('**../footer.html**')} . I am not using ejs loader and I do not use the handlebar plugin. Does somebody know how I can fix this problem and whether it possible to render partials with webpack . Thanks for your advice! 回答1: The feature is called interpolation. Here { test: /\.html$/, use: ['html-loader

PHP - include() or require() with relative paths won't work on windows, even when appending __DIR__

走远了吗. 提交于 2019-12-10 10:09:05
问题 I was reading here about problems in PHP when using include() or required() with relative paths and all the solutions I saw was to append DIR I'm currently working on Windows, and even though the error message displays the current value of DIR , then the relative path seems to be added as a string, rather than going one level up, for example: include(__DIR__ . "..\\another_folder\\file_2.php"); produces the following error: Warning: include(C:\xampp\htdocs\main_folder..\another_folder\file_2

override setTimeout in require.js

倾然丶 夕夏残阳落幕 提交于 2019-12-10 04:13:47
问题 we are using require.js in our project and we need to override the setTimeout in line 705 , this is the code which we need to ignore/omit somehow this setTimeout at all(I mean run over it) ,the problem that if I change it in the open source code explicit when I change version the code will be lost,How should I override this setTimout from outside only for the require.js file and keep it as long as I use this lib, is it possible to do it in elegant way in JS globally ? https://github.com

Common Lisp 函数 require 和 provide 源代码分析

◇◆丶佛笑我妖孽 提交于 2019-12-10 03:34:28
Common Lisp 函数 require 和 provide 源代码分析 === 涉及文件: l1-files.lisp l1-init.lisp 作者: FreeBlues 2013-08-19 === 目录 0 概述 1 源代码: 2 代码分析 2.1 函数 provide 代码分析 2.2 函数 require 代码分析 2.3 其他辅助函数 0 概述 require 使用场景, 使用 quicklisp 安装好一个模块后,该模块实际上并未被自动加载到 lisp 映像中, 所以每次使用该模块之前, 需要执行 (require 模块名) 来加载该模块. provide 使用场景, 自定义模块时, 需要在该模块代码最后一行执行 (provide 模块名) 来保证该模块被加载一次后就把模块名导入到 *module* 列表中. require 用来加载一个模块到 lisp 映像, 如果它已经被加载过, 则保持原样, 不会重新加载(看起来跟 load 函数类似, 不过 load 需要输入文件路径和文件名, 而 require 则只要提供模块名就可以了). 可以指定加载路径, HyperSpec 中有如下几种形式: Examples: ;;; This illustrates a nonportable use of REQUIRE, because it ;;; depends

require.main.require works but not inside Mocha test

孤者浪人 提交于 2019-12-10 02:23:15
问题 I have written a global function for requiring certain files of my app/framework: global.coRequireModel = function(name) { // CRASH happens here return require.main.require('./api/_co' + name + '/_co' + name + '.model'); } This module is in /components/coGlobalFunctions. It is required in my main app app.js like this: require('./components/coGlobalFunctions'); Then in other modules using "something" from the framework I use: var baseScheme = coRequireModel('Base'); This works but not in the

Catch an error on requiring module in node.js

三世轮回 提交于 2019-12-10 01:19:16
问题 Can't seem to find any articles on this anywhere. I basically want to catch the "Cannot find module" error from within the program, and optionally ask to install it, but I can't seem to catch any errors even with a try/catch around my require statements. Is this even possible? I haven't seen it done anywhere. For example: try { var express = require('express'); } catch (err){ console.log("Express is not installed."); //proceed to ask if they would like to install, or quit. //command to run

Apache环境下的php文件在浏览器打不开报错You don't have permission to access this resource.

↘锁芯ラ 提交于 2019-12-10 01:07:27
Apache环境下的php文件在浏览器打不开报错You don’t have permission to access this resource.以下是现在的配置,求大神指点 首先目录下面是如图是一个php文件的目录(有一个php的文件和一个tex的文件,并且运行报错页面)有 其次下面这个是一个我实验是不是因为是php文件的原因的一个目录并且运行页面 下面是Vhosts的配置 AllowOverride none Require all denied <Directory “D:/Web/www”> Options FollowSymLinks AllowOverride None Require all granted 不知道问题在哪。 来源: CSDN 作者: xia199210 链接: https://blog.csdn.net/xia199210/article/details/103459280

koa2 + react + node后台+热更新

▼魔方 西西 提交于 2019-12-09 21:57:21
技术栈 react+webpack 支持前台编写。node+mysql做后台维护 使用ts,包括了tsc,bable7,antd 使用mysql,koa-route 做路由 react+webpack配置 由于使用bable7 ,所以直接使用.babelrc 解析react、ts、es6高级语法 .babelrc相关配置如下,此文件位于项目根目录下。 //.babelrc { "presets": [ [ "@babel/preset-env", { "modules": false } ], ["@babel/preset-react"], ["@babel/preset-typescript"] ], "plugins": [ [ "import", { "libraryName": "antd" } ], [ "@babel/plugin-proposal-class-properties", { "loose": true } ], [ "@babel/plugin-proposal-decorators", { "legacy": true } ], "@babel/plugin-syntax-dynamic-import" ] } 同样需要配置tsconfig.json,此文件位于项目根目录下。内容如下 { "compilerOptions": { "outDir":