转储或dd laravel在结果前添加字符时出错


13

laravel中的所有请求和转储在结果前添加一个^,仅在dd或dump中这样做

错误的例子

例如dd Request:all()

这种影响在我的代码上产生了很多错误,有人过去了吗?


我没有它。
安迪·宋

我认为这是laravel上的配置,我在同一服务器上有另一个项目未显示该项目
Guilherme Freire,

在您的项目上进行搜索,您可能已将该字符硬编码到某个位置。大多数IDE都具有该功能(Find on Path...在phpstorm上)
porloscerrosΨ19/

可以联系。在更新为Laravel 6.2
z0mbieKale,

1
为什么这会在您的代码中产生错误?dd并且dump是调试工具,因此不应在生产代码中使用它们。
Stratadox

Answers:


12

我在laravel框架Lumen(5.8.12)中遇到了相同的问题,并通过返回版本5.8.4解决了该问题。

问题的根源似乎是Symfony VarDumper组件(\ vendor \ symfony \ var-dumper \ Cloner \ Data.php第302行):

$dumper->dumpScalar($cursor, 'default', '^');

应该:

 $dumper->dumpScalar($cursor, 'default', '');

-1

对于简单变量,读取输出应该很简单。以下是一些示例,这些示例首先显示PHP中定义的变量,然后显示其转储表示形式: 检查此链接以获得更好的参考

例如:

 $var = [
'a simple string' => "in an array of 5 elements",
'a float' => 1.0,
'an integer' => 1,
'a boolean' => true,
'an empty array' => [],
 ];
 dump($var);

灰色箭头是一个切换按钮,用于隐藏/显示嵌套结构的子级。

$var = "This is a multi-line string.\n";
$var .= "Hovering a string shows its length.\n";
$var .= "The length of UTF-8 strings is counted in terms of UTF-8 characters.\n";
$var .= "Non-UTF-8 strings length are counted in octet size.\n";
$var .= "Because of this `\xE9` octet (\\xE9),\n";
$var .= "this string is not UTF-8 valid, thus the `b` prefix.\n";
dump($var);

class PropertyExample
{
public $publicProperty = 'The `+` prefix denotes public properties,';
protected $protectedProperty = '`#` protected ones and `-` private ones.';
private $privateProperty = 'Hovering a property shows a reminder.';
}

$var = new PropertyExample();
dump($var);
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.