gpt4 book ai didi

php - 编译错误 : Cannot use positional argument after named argument

转载 作者:行者123 更新时间:2023-12-05 03:28:40 33 4
gpt4 key购买 nike

/**
* @param $name
* @return Response
* @Route ("/afficheN/{name}",name="afficheN")
*/
public function afficheName($name){
return $this->render(view:'student/affiche.html.twig',
['n' => $name]);
}

最佳答案

Php 8 添加了一个名为命名参数的新功能,它允许您根据参数名称而不是参数顺序将输入数据传递给函数。

可以组合命名参数和有序参数,但前提是有序参数在前。

为了让你的代码工作,你有两个选择

  1. 对所有参数使用命名参数:
    return $this->render(view:'student/affiche.html.twig',
parameters:['n' => $name]);
  1. 完全不要使用命名参数:
    return $this->render('student/affiche.html.twig',
['n' => $name]);

Here is a link where you can learn more about named arguments

You can also check the php documentation

关于php - 编译错误 : Cannot use positional argument after named argument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71198154/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com