此页面上有一个包含不同链接的网页.我的目标是找到包含以下内容的链接:/dir/flowers/并拥有类:flower big
并以不同的方式设置它们(即使这些链接成为红色).
以下是应匹配的示例链接:
<a class="flower big" href="http://example.net/dir/flowers/spring.php">Spring</a>
<a class="flower big" href="http://example.net/dir/flowers/winter.php">Winter</a>
<a class="flower big" href="http://example.net/dir/flowers/fall.php">Fall</a>
Run Code Online (Sandbox Code Playgroud)
等等
因此,如果链接包含:/dir/flowers/{*} 并且具有类:"flower big"那么它应该匹配.
我尝试了类似下面的东西,但它不起作用:
(a[class="flower big"] AND a[href~="/dir/flowers/"] ) {color:red}
Run Code Online (Sandbox Code Playgroud) 在 PHP7+ 中有这个新的“空合并运算符”。- http://php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op 它说:
$username = $_GET['user'] ?? 'nobody';
// This is equivalent to:
$username = isset($_GET['user']) ? $_GET['user'] : 'nobody';
Run Code Online (Sandbox Code Playgroud)
在这种情况下,为什么此代码会导致错误/通知:
$username = (int)($_GET['user']) ?? 'nobody';
Run Code Online (Sandbox Code Playgroud)
注意:未定义索引:用户
这是预期的行为(如果是这样,它是否违背了该运算符的目的)?更改(int)为(string)等时的类似通知。
如果我有一组两个单词(用空格分隔),例如:
$str='nice couple';
Run Code Online (Sandbox Code Playgroud)
从每个单词中获取第一个字母的最快(对于服务器处理)方法是什么?IE。最终结果应该是:
数控
我知道我可以使用 $str[0] 并且获得第一个字符 ('n) 将是最快的,但是如何以如此快的方式获得第二个 ('c') 以便我进入最终 ' nc'?