相关疑难解决方法(0)

Reference — What does this symbol mean in PHP?

What is this?

This is a collection of questions that come up every now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this list.

Why is this?

It used to be hard to find questions about operators and other syntax tokens.¹
The main idea is to have links to existing questions on Stack Overflow, so it's easier for us to reference them, not to copy over content from …

php arguments symbols operators

4314
推荐指数
21
解决办法
63万
查看次数

我们在PHP中使用对象运算符" - >"在哪里?

我们可以->在PHP中使用对象运算符的不同方法有哪些?

php

62
推荐指数
3
解决办法
8万
查看次数

这个符号叫什么 =>

这是什么 => 符号在 PHP 中调用。我知道它可以解释为等号直角括号。| 可以称为 Pipe 或 OR。但我的教授要求另一个术语调用 => 符号。它用于为数组类中的键赋值。有谁知道这叫什么?

php symbols

4
推荐指数
1
解决办法
1596
查看次数

Laravel正则表达式验证价格或空

我试图为价格制作正则表达式或空.我有价格部分(荷兰语使用逗号而不是点数)实际上有效

/^\d+(,\d{1,2})?$/
Run Code Online (Sandbox Code Playgroud)

上面的正则表达式在值21,99上验证了ok

现在我尝试添加空部分,以便字段可以......只是空^ $

/(^$|^\d+(,\d{1,2})?$)/
Run Code Online (Sandbox Code Playgroud)

但是当我改变正则表达式时,Laravel开始抱怨:"方法[验证^\d +(,\ d {1,2})?$)/]不存在."

工作正常:

$rules = [
    'price' => 'regex:/^\d+(,\d{1,2})?$/'
];
Run Code Online (Sandbox Code Playgroud)

Laravel说没有......:

$rules = [
    'price' => 'regex:/(^$|^\d+(,\d{1,2})?$)/'
];
Run Code Online (Sandbox Code Playgroud)

Kenken9990回答 - Laravel不再破坏,但空值仍然是错误的:

$rules = [
    'price' => 'regex:/^(\d+(,\d{1,2})?)?$/'
];
Run Code Online (Sandbox Code Playgroud)

php regex laravel

3
推荐指数
1
解决办法
1877
查看次数

标签 统计

php ×4

symbols ×2

arguments ×1

laravel ×1

operators ×1

regex ×1