我有一个{{render(path('route'))}}函数,我需要附加一个参数的查询字符串.我怎样才能做到这一点?
目前我有这个:
{{ render(path('page_load', { 'name': name, 'hook': hook ... need to append a dynamic query string ... })) }}
Run Code Online (Sandbox Code Playgroud)
如果定义,我需要附加此查询字符串:
{% if queryString is defined and queryString|trim != '' %}?{{ queryString }}{% endif %}
Run Code Online (Sandbox Code Playgroud)
弄清楚了:
{% set string = '' %}
{% if queryString is defined and queryString is not null %}
{% set string = '?' ~ queryString %}
{% endif %}
{{ render(path('page_load', { 'name': name, 'hook': hook}) ~ string) }}
Run Code Online (Sandbox Code Playgroud) 我试图在我的控制器中访问getName(),但它无法正常工作.
这DOES NOT工作:
$supplier = $em->getRepository('WICSupplierBundle:Supplier')->findBy(array('account'=>$account_id, 'id'=>$id));
$supplierName = $supplier->getName();
This doesnt return the name from the db....
I get the error: "Error: Call to a member function getName() on a non-object..."
Run Code Online (Sandbox Code Playgroud)
这个DOES有效:
$supplier = $em->getRepository('WICSupplierBundle:Supplier')->find($id);
$supplierName = $supplier->getName();
This returns the name from the db....
Run Code Online (Sandbox Code Playgroud)
为什么?
我正在使用 PHP,并且尝试删除字符串末尾和开头的所有下划线字符。
这是字符串:____a_b_c__________
我希望结果是:a_b_c
我尝试过这个正则表达式,但它不起作用:
preg_replace('/[^a-z]+\Z/i', '', '____a_b_c__________');
Run Code Online (Sandbox Code Playgroud) 我正在使用PHP。
我有一串这样的文字:
mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=OvtBcHsM; spf=pass (google.com: domain of xxxx@outlook.com designates 12.12.12.12 as permitted sender) smtp.mailfrom=xxxx@outlook.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com
Run Code Online (Sandbox Code Playgroud)
我需要从中提取电子邮件地址(请记住,该电子邮件地址可以是一百万个不同的变体):
smtp.mailfrom=xxxx@outlook.com;
Run Code Online (Sandbox Code Playgroud)
这样我就结束了:
xxxx@outlook.com;
Run Code Online (Sandbox Code Playgroud)
如何做到这一点?谢谢!