小编Jor*_*eFG的帖子

PHP正则表达式(+和*之间的结果不同)

如果我把*放在我的正则表达式中,它就不起作用,如果我放+,它就可以了.

*应该是0或更多,+应该是1或更多.


案例*

$num = '    527545855   ';
var_dump( preg_match( '/\d*/', substr( $num, 0, 18 ), $coincidencias ) );
var_dump($coincidencias);exit;
Run Code Online (Sandbox Code Playgroud)

结果:

int(1)
array(1) {
  [0]=>
  string(0) ""
}
Run Code Online (Sandbox Code Playgroud)

案例+

$num = '    527545855   ';
var_dump( preg_match( '/\d+/', substr( $num, 0, 18 ), $coincidencias ) );
var_dump($coincidencias);exit;
Run Code Online (Sandbox Code Playgroud)

结果:

int(1)
array(1) {
  [0]=>
  string(9) "527545855"
}
Run Code Online (Sandbox Code Playgroud)

我认为两者都应该有效,但我不明白为什么*不起作用.

php regex

5
推荐指数
2
解决办法
113
查看次数

ul列中的2列li,不会填充100%的ul宽度

我不能让UL的li元素填充100%的宽度(或接近).

发生了一些奇怪的事情,因为第一列与父母的咆哮者相邻,但第二列与右侧父母的边界相差20磅.

在此输入图像描述

.latest-posts .latest-posts-widget ul {
    border: solid 1px;
}

.latest-posts .latest-posts-widget ul li {
    display: inline-block;
    width: 49%;
    border: solid 1px;
}
Run Code Online (Sandbox Code Playgroud)

它受Bootstrap 3的影响

此外,我必须使用49%,因为50%不会使2列

Live page is under development in [www.hugotrinchero.com.ar][2]
Run Code Online (Sandbox Code Playgroud)

html css3

5
推荐指数
2
解决办法
568
查看次数

如何在出错时更改PhpStorm主题箱/控制台背景颜色/字体颜色

在黑暗的控制台中很难看到文字.

我怎样才能改变这些颜色?

在此输入图像描述

我正在使用PhpStorm Darcula主题

phpstorm

5
推荐指数
1
解决办法
922
查看次数

如何实现303重定向?

我想知道如何实现303重定向显示post数据.

例:

I send the form.

Redirect

Page displays the info I just posted. (Eg: Name, email).
Run Code Online (Sandbox Code Playgroud)

我认为它是用参数完成的,/index.php?name=TheName&email=theEmail但我不确定,因为我试图找到一些好的文章解释它但不能.

非常感谢.

php redirect http-headers

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

在MySQL + PDO中显示警告

我想知道如何在MySQL + PDO中获取警告计数.

在控制台中进行查询时,我发出警告,寻找varchar而不是添加aphostrophes(' ').

mysql> describe keywords;
+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| id          | int(11)      | NO   | PRI | NULL    | auto_increment |
| document_id | int(11)      | NO   | MUL | NULL    |                |
| keyword     | char(50)     | NO   |     | NULL    |                |
| value       | varchar(250) | YES  |     | NULL    |                |
+-------------+--------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

mysql> …
Run Code Online (Sandbox Code Playgroud)

php mysql pdo

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

VB.net无法继承

我是VB.net的新手,我无法编译这段代码,我不明白为什么.

MustInherit Class Poligono

    Protected p_cant_Lados As Integer
    Public Property cant_Lados() As Integer
        Get
            Return p_cant_Lados
        End Get
        Set(ByVal value As Integer)
            p_cant_Lados = value
        End Set
    End Property

    Public MustOverride Function obtenerPerimetro()
    Public MustOverride Function cargarLados()

End Class

Public Class Triangulo
    Inherits Poligono

    Private lado1 As Integer
    Private lado2 As Integer
    Private lado3 As Integer

    Public Function cargarLados() As Object
        Return 1
    End Function

    Public Function obtenerPerimetro() As Object
        Return 1
    End Function

End Class
Run Code Online (Sandbox Code Playgroud)

错误2'Triangulo'不能从类'Poligono'继承,因为它扩展了程序集外部基类的访问.c:\ users\win7\documents\visual studio 2013\Projects\WindowsApplication1\WindowsApplication1\Form1.vb …

vb.net

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

学说 2 不创建外键

我在实体中有这段代码:

/**
 * @ORM\ManyToOne(targetEntity="Centers")
 * @ORM\JoinColumn(name="center_id", referencedColumnName="id")
 * @ORM\Column(type="string", length=36, name="center_id")
 */
protected $centerId;
Run Code Online (Sandbox Code Playgroud)

然而,schema:update说一切都是同步的。即使将 Centers 更改为其他一些不存在的词,也不会产生错误。

symfony doctrine-orm

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

如何自定义主题中的get_the_post_navigation

get_the_post_navigation() 函数定义在里面 wp-includes/link-template.php

如何在主题中覆盖它?

wordpress wordpress-theming

2
推荐指数
1
解决办法
6086
查看次数

字符串连接中的 Python 内联条件

我有这个:

msg = time + b' - ' + Logger.LEVELS_WORD[msg_loglevel] + b': ' + msg.encode('utf-8') + b'\n'
Run Code Online (Sandbox Code Playgroud)

由于有时 msg 已经是字节,如果它是字符串或者只是 msg,我想连接 msg.encode('utf-8'),所以我这样做了:

msg = time + b' - ' + Logger.LEVELS_WORD[msg_loglevel] + b': ' + msg if isinstance(msg, bytes) else msg.encode('utf-8') + b'\n'
Run Code Online (Sandbox Code Playgroud)

但它并没有像我预期的那样工作,因为现在msg equals msg。(时间 + 日志级别没有被添加)。

我应该做 if/else 吗?

python conditional-expressions

2
推荐指数
1
解决办法
5879
查看次数

Symfony 控制器即服务如何与 __invoke 方法一起工作?

例如,在以下代码中:

/**
 * @Route("/patients", service="bundle1.controller.patient.index")
 */
final class IndexController
{
    private $router;
    private $formFactory;
    private $templating;
    private $patientFinder;

    public function __construct(RouterInterface $router, FormFactoryInterface $formFactory, EngineInterface $templating, PatientFinder $patientFinder)
    {
        $this->router = $router;
        $this->formFactory = $formFactory;
        $this->templating = $templating;
        $this->patientFinder = $patientFinder;
    }

    /**
     * @Route("", name="patients_index")
     */
    public function __invoke(Request $request) : Response
    {
        $form = $this->formFactory->create(PatientFilterType::class, null, [
            'action' => $this->router->generate('patients_index'),
            'method' => Request::METHOD_GET,
        ]);
        $form->handleRequest($request);
        $patients = $this->patientFinder->matching($form->getData() ?: []);

        return $this->templating->renderResponse('patient/index.html.twig', [
            'form' => $form->createView(),
            'patients' => …
Run Code Online (Sandbox Code Playgroud)

service symfony

2
推荐指数
1
解决办法
6674
查看次数