我想问一下PHP克隆/复制对象到$ this变量.
目前我是MVC的新手,我想做CodeIgniter之类的事情.
我想直接访问变量.
在我的__construct()中,我总是将全局变量传递给新的控制器(类),
例如.
function __construct($mvc)
{
$this->mvc = $mvc;
}
Run Code Online (Sandbox Code Playgroud)
在$ mvc里面得到了配置对象,vars对象.
例如,目前
function index()
{
$this->mvc->config['title'];
$this->mvc->vars['name'];
}
Run Code Online (Sandbox Code Playgroud)
**我想要的更直接**
function index()
{
$this->config['title'];
$this->vars['name'];
}
Run Code Online (Sandbox Code Playgroud)
我试过了
function __construct($mvc)
{
$this = $mvc;
}
Run Code Online (Sandbox Code Playgroud)
要么
function __construct($mvc)
{
$this = clone $mvc;
}
Run Code Online (Sandbox Code Playgroud)
它不成功.任何想法,我可以关闭$ this-> mvc到$这个级别?我尝试foreach也没有成功.请帮忙,谢谢!
我正在尝试提交一个表单链接.为什么命名提交输入元素submit,链接不再有效?
//breaks form submission
<input type="submit" value="Submit" name="submit" />
//does not break form submission
<input type="submit" value="Submit" name="xsubmit" />
Run Code Online (Sandbox Code Playgroud)
在Chrome中,我收到以下错误消息.
Uncaught TypeError: Property 'submit' of object #<HTMLFormElement> is not a function
Run Code Online (Sandbox Code Playgroud)
不工作
<p>Type 'correct' to validate.</p>
<form method="post" enctype="multipart/form-data">
<input type="submit" value="Submit" name="submit" />
<a id="btn_submit">
<span id="txt_submit">Submit</span>
</a>
</form>
<script>
$("#btn_submit").click(function() {
$("form").submit();
});
$("form").submit(function() {
});
</script>
Run Code Online (Sandbox Code Playgroud)
工作
<p>Type 'correct' to validate.</p>
<form method="post" enctype="multipart/form-data">
<input type="submit" value="Submit" name="xsubmit" />
<a id="btn_submit">
<span id="txt_submit">Submit</span>
</a>
</form> …Run Code Online (Sandbox Code Playgroud) file:app/route.php
Route::get('/', function()
{
return View::make('home');
});
Run Code Online (Sandbox Code Playgroud)
file:app/views/home.blade.php
{{-- Blade comment. --}}
@extends('layouts.base')
@section('head')
<link rel="stylesheet" href="second.css" />
@stop
@section('body')
<h1>Heading</h1>
<p>Hello Home!</p>
@stop
Run Code Online (Sandbox Code Playgroud)
file:app/views/layouts/base.blade.php
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
@section('head')
<link rel="stylesheet" href="style.css" />
@show
</head>
<body>
@yield('body')
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当我访问laravel.localhost /它只输出@extends('layouts.base')
但是,如果我删除了
{{ - 刀片评论. - }}
然后它完美地运作.
我可以知道这是什么问题吗?
我需要将数字舍入到最接近的千位数.我试过了round($x, -3),但输出并不是我想要的.
所需输出的示例:
999 => 1,000
1,000.0001 => 2,000
1,001 => 2,000
1,100 => 2,000
1,600 => 2,000
100,010 => 101,000
Run Code Online (Sandbox Code Playgroud)