我可以以某种方式从另一个类方法获取构造函数参数的值而不直接传递它们吗?
我试图使用这些方法,\ReflectionClass但只能获取属性的名称.如何获取带有值的参数名称?
Counts,types和values,以及names参数是事先不知道的.
<?php
class Report extends AbstractReport
{
public function __construct($month, $year)
{
$this->month = $month;
$this->year = $year;
}
}
class Report2 extends AbstractReport
{
public function __construct($day, $month, $year, $type = null)
{
$this->day = $day;
$this->month = $month;
$this->year = $year;
$this->type = $type;
}
}
class AbstractReport
{
/**
* Return contructor parameters array
* @return array
*/
public function getParameters()
{
$ref = new \ReflectionClass($this); …Run Code Online (Sandbox Code Playgroud) 我尝试使用客户数据自动填写newsletter2go表单.表单是使用javascript代码动态创建的,我是从newsletter2go后端获得的.
但我发现,如果我使用javascript填充它,表单将不再起作用了!?如果我手动填充它,它的工作原理非常好.
我从开发者控制台执行了这段代码:
var inputEmail = document.getElementsByClassName("newsletterInput")[0],
inputVorname = document.getElementsByClassName("newsletterInput")[1],
inputNachname = document.getElementsByClassName("newsletterInput")[2],
selectAnrede = document.getElementsByClassName("newsletterSelect")[0];
if (inputEmail.value == "") {
inputEmail.value = 'foo@bar.de';
}
if (selectAnrede.value == "") {
selectAnrede.value = 'm';
}
if (inputVorname.value == "") {
inputVorname.value = 'Edward';
}
if (inputNachname.value == "") {
inputNachname.value = 'Black';
}
Run Code Online (Sandbox Code Playgroud)
表格已经填满,但如果我提交,那么我会看到抱歉,发生了错误.请检查您的数据.
为什么会失败?
如果浏览器自动填写表单,那么它的工作顺便说一句.
我使用这个 CSS 作为我的 CSS 网格声明:
#slider_area {
grid-template: 1fr 1fr 1fr / 1fr 32%;
grid-column-gap: 8px;
grid-row-gap: 4px;
}
Run Code Online (Sandbox Code Playgroud)
但它转换为:
#slider_area {
grid-template: 1fr 1fr 1fr 32%;
grid-column-gap: 8px;
grid-row-gap: 4px;
}
Run Code Online (Sandbox Code Playgroud)
在我的 LESS 中,页面视图中断。
您可以在这里检查:
https://www.webtoolkitonline.com/less-to-css.html
如果是错误,我可以在哪里报告它?有解决方法吗?
我正在尝试将字符串的所有字母转换为字母表的后续字母,例如A应该变为B,X应该变为Y,Z应该变为A等.
我想在完成字母转换后将每个元音都大写.
function LetterChanges(str) {
var c = str.split("");
var vowels = ["a", "e", "i", "o", "u"];
if (c == vowels) {
vowels.toUpperCase();}
if (c == "z") return "a";
return str.replace(/[a-z]/gi, function(s) {
return String.fromCharCode(s.charCodeAt(c)+1);
});
}
LetterChanges("cold buttz");
Run Code Online (Sandbox Code Playgroud)
元音部分和z对a部分不能正常工作.请帮忙?
正如您在运行代码后所看到的,我有多个表,让我们假设它们是使用PHP动态创建的.tbody如果我点击它,我会尝试隐藏/显示整个表格thead.
我可以给每个表它自己的id并为每个表编写jquery代码......但由于这些表是动态创建的,所以我不能像这样解决它.
如果我点击thead,我的jquery脚本的当前版本切换所有tbody,而不是仅仅我实际点击的表格的那个.
我解决这个问题的唯一想法是动态创建jquery代码(但我不确定这是否真的有效),但在我尝试之前,有人知道是否有更简单的解决方案吗?
我想过这样的事情:
$("this tbody").css("display","none");
Run Code Online (Sandbox Code Playgroud)
所以它只选择我实际点击的thead的tbody.
var main = function()
{
$toggle = true;
$("thead").click
(
function()
{
if ($toggle)
{
$toggle = false;
$("tbody").css("display","none");
}
else
{
$toggle = true;
$("tbody").css("display","");
}
}
);
}
$(document).ready(main);Run Code Online (Sandbox Code Playgroud)
table, td {
border: 1px solid black;
}
td {
color: red;
display: block;
max-width: 120px;
white-space: nowrap;
overflow-x: auto;
background-color: blue;
}
th {
border: 1px solid black;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<thead>
<tr><th id="here1">First Table</th></tr> …Run Code Online (Sandbox Code Playgroud)我尝试每隔2秒输出一个警告框,其中包含"hello"消息,但只有5次.所以我写了这段代码:
var counter = 1;
do {
setTimeout
(
function()
{
alert("hello");
counter++;
},
2000
);
} while( counter <= 5 );
Run Code Online (Sandbox Code Playgroud)
但我的页面每次都在崩溃?为什么?什么是在警报之间添加延迟2000毫秒的最佳方法?
我尝试修改扩展importr以将自定义操作插入到importr\Classes\Controller\ImportrController.php的控制器“Importr”中。
我将操作称为“customAction”,并从一个按钮引用它,我使用importr\Resources\Private\Templates\Importr\Index.html中的流体渲染该按钮<f:link.action>
<div id="myButton">
<f:link.action
extensionName="Importr"
pluginName="Importr"
controller="Importr"
action="custom"
arguments="{taskid:5}"
>
Click here
</f:link.action>
</div>
Run Code Online (Sandbox Code Playgroud)
控制器动作:
/**
* @param int $taskid
* @return void
*/
public function customAction($taskid)
{
...
}
Run Code Online (Sandbox Code Playgroud)
但是,每次尝试将参数传递给操作都会失败。在我的第一次尝试中,我什至没有单击按钮就收到错误页面,如下面的屏幕截图所示。
尝试#1
/**
* @param int $taskid
* @return void
*/
public function customAction($taskid)
{
print_r($taskid);
die;
}
Run Code Online (Sandbox Code Playgroud)
未捕获的 TYPO3 异常
1298012500:未为 HDNET\Importr\Controller\ImportrController->custom 设置必需的参数“taskid”。
TYPO3\CMS\Extbase\Mvc\Controller\Exception\RequiredArgumentMissingException 在文件 /var/www/typo3/typo3_src-6.2.25/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php 第 425 行中抛出。
尝试#2
/**
* @return void
*/
public function customAction()
{
$taskid = "default";
if …Run Code Online (Sandbox Code Playgroud) 我想提交一个表单,但是Action App\Http\Controllers\About@show not defined即使函数show已定义,我也总是可以得到:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
class AboutController extends Controller
{
public function create()
{
return view('about.contact');
}
public function show()
{
return view('about.contactshow');
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的刀片模板about\contact.blade.php:
{!! Form::open(array('action' => 'About@show', 'method' => 'post')) !!}
{!! Form::label('username','Username',array('id'=>'user','class'=>'')) !!}
{!! Form::text('username','user 1',array('id'=>'user','class'=>'', 'placeholder' => 'user 1')) !!}
{!! Form::submit('Click Me!') !!}
{!! Form::close() !!}
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我尝试编写自己的寄存器控制器,但在文档中没有提到laravel使用哪种哈希算法.
使用哪一个?
javascript ×4
php ×3
css ×2
laravel ×2
constructor ×1
css-grid ×1
html ×1
jquery ×1
laravel-5.2 ×1
laravel-5.4 ×1
less ×1
newsletter ×1
parameters ×1
settimeout ×1
string ×1
typo3 ×1
typo3-6.2.x ×1
while-loop ×1