我希望用户从两个选项中进行选择,这将决定单个字符串的含义。
最终我将用变量构建一个句子。
这可能没有多大意义,我是一个全新的人,我是为了自己的充实而这样做。我知道可能有很多更好的方法来构造它,但是我想自己做大部分事情,让别人看看我完成的项目,并解释我可以做些什么并指导我。首先,还是第一件事。
我有这个的工作版本,但没有双重条件的IF语句。另外,我在该项目下有一个用于构造变量的类,主类程序将生成输出。
public function userEditProfileAction(Request $request)
{
$user = $this->get('security.token_storage')->getToken()->getUser();
if ($user instanceof User && $user->hasRole('ROLE_USER'))
{
$basicForm = $this->createForm(UserEditBasicInfoType::class, $user);
$additionalData = $this->getDoctrine()->getRepository(UserAdditionalData::class)->findOneByUser($user);
$additionalForm = $this->createForm(UserAdditionalDataType::class, $additionalData);
$notificationInfoData = $this->getDoctrine()->getRepository(NotificationInfo::class)->findOneByUser($user);
$notificationInfoForm = $this->createForm(NotificationInfoType::class, $notificationInfoData);
$basicForm->handleRequest($request);
$additionalForm->handleRequest($request);
$notificationInfoForm->handleRequest($request);
if (($basicForm->isSubmitted() && $basicForm->isValid()) ||
($additionalForm->isSubmitted() && $additionalForm->isValid()) ||
($notificationInfoForm->isSubmitted() && $notificationInfoForm->isValid())
)
{
$this->getDoctrine()->getManager()->flush();
$this->addFlash('success', 'Pomyślnie zmioniono dane.');
$this->redirectToRoute('user_profile');
}
return $this->render('FrontBundle:Default:user-profile.html.twig', array(
'user' => $user,
'additional_data' => $additionalData,
'notification_info_data' => $notificationInfoData,
'basic_form' => $basicForm->createView(),
'additional_form' => $additionalForm->createView(),
'notification_info_form' => $notificationInfoForm->createView()
));
} else
{
return $this->redirectToRoute('user_login');
}
}
if (($basicForm->isSubmitted() && $basicForm->isValid()) ||
($additionalForm->isSubmitted() && $additionalForm->isValid()) ||
($notificationInfoForm->isSubmitted() && $notificationInfoForm->isValid())
)
{
...
} else {
$this->get('doctrine')->getManager()->refresh($this->getUser());
}
引发错误
运算符&&不适用于bool和int类型的操作数
答案 0 :(得分:1)
if(KP.Key == ConsoleKey.NumPad1 && hr = 1)引发错误运算符 &&不能应用于bool和int类型的操作数
尝试“ ==”:如果(KP.Key == ConsoleKey.NumPad1 && hr == 1)