我在主目录中创建了5个包含5个类(Ad_Class,Blocked_Class,Friend_Class,Image_Class,Profile_Class)的文件夹.我还在所提到的文件夹中创建了相应的类,并使用确切的名称作为文件夹.即,如果文件夹名称是Ad_Class,则文件夹中的类也与"类Ad_Class"中的文件夹名称相同.
在index.php文件中,我编写了以下代码:
function Ad_Class($name)
{
include "Ad_Class/$name.php";
}
function Blocked_Class($name)
{
include "Blocked_Class/$name.php";
}
function Friend_Class($name)
{
include "Friend_Class/$name.php";
}
function Image_Class($name)
{
include "Image_Class/$name.php";
}
function Profile_Class($name)
{
include "Profile_Class/$name.php";
}
spl_autoload_register("Ad_Class");
spl_autoload_register("Blocked_Class");
spl_autoload_register("Friend_Class");
spl_autoload_register("Image_Class");
spl_autoload_register("Profile_Class");
$a = new Ad_Class;
$b = new Blocked_Class;
$c = new Blocked_Class;
$d = new Image_Class;
$e = new Profile_Class;
Run Code Online (Sandbox Code Playgroud)
执行上面的代码后,我收到以下警告:
Warning: include(Ad_Class/Blocked_Class.php): failed to open stream: No such file or directory in C:\Users\Robert\Documents\web development\xampp\htdocs\xampp\web_development\development.php on line 4
Warning: include(): Failed opening 'Ad_Class/Blocked_Class.php' …Run Code Online (Sandbox Code Playgroud) 我有以下脚本
document.write("12" < "2");
Run Code Online (Sandbox Code Playgroud)
返回true.有什么理由吗?文档说javascript在数字上比较字符串但是,我不知道"12"是如何小于"2".
假设我有:
SET @fname := "James", @mname := "Robert", @lname := "Maxon";
Run Code Online (Sandbox Code Playgroud)
我将如何设置一个包含上述变量连接结果的变量?
我有:
function outside( $limit ) {
$tally = 0;
return function() use ( $limit, &$tally ) {
$tally++;
if( $tally > $limit ) {
echo "limit has been exceeded";
}
};
}
$inside = outside( 2 );
$inside();
$inside();
$inside();
Run Code Online (Sandbox Code Playgroud)
输出: limit has been exceeded
我的理解:
on $inside = outside( 2 );将返回匿名函数并将其分配给变量$inside.匿名函数使用值$limit(2)和$tally(0).
函数$inside()被调用.此增量$tally为1以某种方式记住该值,因此也是如此$limit.以前&符号的目的是什么$tally?我知道它用于创建引用,但在这种情况下它让我感到困惑.这个闭包怎么能记住它的价值$limit?
任何对官方文档的引用都会有帮助!
我编写了下面的代码来输出文件的内容两次.但它只做了一次.这是为什么?
文本文件内容如下:
My name is Sam. Sam I am.
My name is Chris and Chris I am.
The brown fox jumped over the fence.
Run Code Online (Sandbox Code Playgroud)
代码如下:
<?php
$file = "files/info.txt";
$handle = fopen($file, "rb");
echo fread($handle, filesize($file));
echo fread($handle, filesize($file));
?>
Run Code Online (Sandbox Code Playgroud)
输出:
"My name is Sam. Sam I am. My name is Chris and Chris I am. The brown fox jumped over the fence."
Run Code Online (Sandbox Code Playgroud) 我有:
create table `products`
(
`id` int(11) not null auto_increment,
`price` float(255),
`weight` int(11),
`sku` varchar(255),
`stock_level` int(11),
`image` mediumblob(1000),
`search_engine_name` varchar(255),
`description` varchar(1000),
`url` varchar(255),
`category` varchar(255),
primary key (`id`)
);
Run Code Online (Sandbox Code Playgroud)
MySql输出:"列'价格'的列说明符不正确
为什么是这样?
我正在尝试克隆一个简单的div并将其插入其后:
$(document).ready(function() {
// clone and append
$("div").clone().appendTo("div");
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div style="height: 10px; background-color: blue; width: 600px; margin-bottom:1px"></div>Run Code Online (Sandbox Code Playgroud)
为什么这没有按我预期的那样工作?
ul a:first-of-type {
color: red;
}Run Code Online (Sandbox Code Playgroud)
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li><a href="#">Item 3</a>
</li>
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
<li>Item 7</li>
<li>Item 8</li>
<li>Item 9</li>
<li>Item 10</li>
<li>Item 11</li>
<li><a href="#">Item 12</a>
</li>
<li>Item 13</li>
<li>Item 14</li>
<li>Item 15</li>
<li>Item 16</li>
</ul>Run Code Online (Sandbox Code Playgroud)
为什么a选择项目12?它不是同类型的第一个兄弟,它是最后一个.
我有一个简单的网格,我正在测试.
我决定从一些改变float: left,以display: inline-block在属性选择[class*='col-].
我想知道为什么当使用时float: left有足够的空间col-9,一切正常,但是,当使用display: inline-block元素下降到下一行.
* {
box-sizing: border-box;
}
.header {
border: 1px solid red;
padding: 15px;
}
.col-1 {width: 8.33%;}
.col-2 {width: 16.66%;}
.col-3 {width: 25%;}
.col-4 {width: 33.33%;}
.col-5 {width: 41.66%;}
.col-6 {width: 50%;}
.col-7 {width: 58.33%;}
.col-8 {width: 66.66%;}
.col-9 {width: 75%;}
.col-10 {width: 83.33%;}
.col-11 {width: 91.66%;}
.col-12 {width: 100%;}
[class*='col-'] {
display: inline-block;
padding-top: 15px;
border: 1px solid red;
} …Run Code Online (Sandbox Code Playgroud)Laravel 版本:5.1.46
路线.php
Route::get('/rocha', 'RochaController@index');
内核.php
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'Age' => \App\Http\Middleware\AgeMiddleware::class,
'Role' => \App\Http\Middleware\RoleMiddleware::class,
];
Run Code Online (Sandbox Code Playgroud)
RochaController.php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class RochaController extends Controller
{
public function __construct() {
$this->middleware('Role');
}
public function index() {
echo '<br>Hi I am index';
}
}
Run Code Online (Sandbox Code Playgroud)
RochaMiddleware.php
namespace App\Http\Middleware;
use Closure;
class RoleMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next …Run Code Online (Sandbox Code Playgroud)