例如 - 此函数使用外观:
File::get('path/to/file.txt');
Run Code Online (Sandbox Code Playgroud)
事实证明,实际供应的基础类File::get是Illuminate\Filesystem\Filesystem
我查看了Laravel 4.2文档 - 这就是我使用的版本 - 以及api参考,但我找不到任何可以解释如何提前知道如何找到"真正的"类到门面的人.
关于Laravel外墙的这个教程给出了一个涉及的方法
File班级FacadeFacade#__callstatic()方法遵循代码__callstatic(),resolveFacadeInstance()当getFacadeAccessor()返回字符串files 这是对最新情况的一个很好的证明,但我不想经常这样做.
我的问题是,知道你在你的app中使用的"facaded classes"不一定有相同的名称或一些约定来帮助你搜索文件系统,怎么会有人 - 谁不知道底层的类是什么 - 找到laravel外观的基础类?
我使用在vim中创建了一个空白的"临时缓冲区"(即与特定文件无关):vnew.然后我玩了一些文本,现在我只想退出编辑器 - 不保留这个"临时缓冲区"的内容.
当我输入命令时:
:q!
Run Code Online (Sandbox Code Playgroud)
Vim给了我:
[No Name][+]
E37: No write since last change (add ! to override)
E162: No write since last change for buffer "[No Name]"
Press ENTER or type command to continue
Run Code Online (Sandbox Code Playgroud)
我怎样才能从这个状态退出vim?
根据大多数IDE,当您键入函数的一部分时(假设IDE配置正确等),PhpStorm将显示匹配选项列表.
PhpStorm还将显示函数签名,这是理想的,当你有一个接受大量参数的函数时提供提示,例如数据库连接函数mysqli_connect.
但是,当您"选择"自动完成功能时,无论是通过ctrl + spacebar下拉菜单还是从下拉菜单中选择,方法签名和参数提示都会消失.
我试过了:
ctrl + space 这会再次显示自动完成菜单,但您必须摆弄窗口才能查看参数,然后当您开始输入时它会再次消失,如果您需要再次参考,则需要再次查看窗口大小调整过程.ctrl + q 快速文档 - 这不会做任何事情有没有办法在键入函数的参数时重新启动方法签名?
在研究如何用HTML编写表单时,我会提到“表单控件”一词。
特别是使用Twitter Bootstrap,它具有类似form-control和的类control-label。
什么是“表单控件”?
我有简单的角度js控制器,如下所示发出XHR请求
app.controller('MainController', ['$http', function($http) {
this.php_response = {};
var promise = $http.get('process.php');
promise.then(
function(success_data) {
// I dont think "this" is talking to the controller this anymore?
this.php_response = success_data;
}, function(error) {
console.log('there was a problem');
}
);
}]);
Run Code Online (Sandbox Code Playgroud)
当我使用$scope代码而不是代码编写此控制器时,现在该this.php_response属性不包含从XHR请求中检索的数据.
我怀疑promise.then#success回调不再引用控制器this.
如何在promise方法中访问它?
如果我定义一个函数:
function foo() {
alert(this.x);
}
Run Code Online (Sandbox Code Playgroud)
我可以通过调用函数toString上的方法来打印函数定义foo.
console.log(foo.toString())
Run Code Online (Sandbox Code Playgroud)
输出:
function foo(){alert(this.x); }
如果我然后跑
console.log(Object.prototype.toString.call(foo))
Run Code Online (Sandbox Code Playgroud)
输出:
"[对象功能]"
令我惊讶的是输出不同.我认为这两种形式是等价的?,即foo函数toString从顶层继承了方法,Object而使用的Object.prototype.toString.call(foo)只是调用toString传递foo函数作为this.
这两种形式的调用有什么区别?
当浏览器在 POST 请求正文中发送数据(即name=value来自表单元素的对)时,PHP 如何确定字符编码,以便它可以正确地将位流解码为字符以供其内部使用?
我可以理解,对于某些 PHP 不需要解码的任务,例如对于 SQL INSERT 查询,它可能只是将数据/字符串传递到 DBMS,而不进行额外的处理。
但对于文本处理/正则表达式操作,我想 PHP 需要将位流解码为字符,然后才能对它们执行测试、模式匹配等。
另外,似乎因为编码是由浏览器决定的,所以 PHP 需要浏览器的指导来确定它使用什么字符集来编码 POST 数据。
预计该指导将出现在请求标头中,我设置了一个文本表单
<meta charset="utf-8">
Run Code Online (Sandbox Code Playgroud)
在包含表单的网页的头部,输入一些值并提交表单后,请求标头不包含有关如何编码 POST 数据的明显信息
POST /experiments/foo.php HTTP/1.1
Host: localhost
Connection: keep-alive
Content-Length: 57
Pragma: no-cache
Cache-Control: no-cache
Origin: http://localhost
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Referer: http://localhost/experiments/how_does_php_encode_data_it_receives_from_browser.php
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
Run Code Online (Sandbox Code Playgroud)
还是还有其他事情发生?例如,浏览器是否需要按照某种预先确定的标准对字符进行编码?
PHP 如何知道如何解码从浏览器 POST 请求接收到的数据?
在 vim 中编写 bash 脚本时,能够有选择地只运行脚本中的几行会很有用,例如,如果我有一些脚本
#! /bin/bash
# more commands
mkdir /tmp/test_dir
echo "some output to STDOUT"
touch /tmp/test_dir/new_file
# more commands
Run Code Online (Sandbox Code Playgroud)
说我只想执行这部分脚本
mkdir /tmp/test_dir
echo "some output to STDOUT"
touch /tmp/test_dir/new_file
Run Code Online (Sandbox Code Playgroud)
如何在 vim 中突出显示并执行它?我试过了
v, 选择目标文本, :这给出了一个提示 :'<, '>
然后尝试 :! w
但它不能正常工作。
我不需要将 shell 命令的 STDOUT 写入文件或任何东西,但我希望至少能够看到输出。
我正在使用git并尝试合并导致合并冲突的分支.
我试图配置vimdiff为mergetool
git config merge.tool vimdiff
git config merge.conflictstyle diff3
git config mergetool.prompt false
Run Code Online (Sandbox Code Playgroud)
这是正在发生的事情
$ git merge master
CONFLICT (rename/delete): dev_tools+env_config/gnome-term_+_bash+tmux.sh deleted in HEAD and renamed in master.
Version master of dev_tools+env_config/gnome-term_+_bash+tmux.sh left in tree.
Automatic merge failed; fix conflicts and then commit the result.
$ git status
On branch breaking_changes_test
You have unmerged paths.
(fix conflicts and run "git commit")
Unmerged paths:
(use "git add <file>..." to mark resolution)
added by them: dev_tools+env_config/gnome-term_+_bash+tmux.sh
no changes added …Run Code Online (Sandbox Code Playgroud) 我正在尝试注册一个事件处理程序,当按钮触发单击事件时,它将一个元素附加到 DOM 中,例如
var b = document.getElementById('evt');
var eventDemo = function(event) {
console.log('I handled the event');
console.log(event);
console.log(Object.prototype.toString.call(event));
var imgElement = document.createElement('img');
imgElement.src = 'http://lorempixel.com/150/150/';
document.body.appendChild(imgElement);
};
b.addEventListener('onclick', eventDemo, false);
Run Code Online (Sandbox Code Playgroud)
但我不断得到:
未捕获的类型错误:无法读取 null 的属性“addEventListener”
为什么会发生这种情况
浏览器: 铬