drhib62644 2011-09-08 21:50
浏览 57
已采纳

这个T_IF错误是什么意思?

<?php
$to = "service@mysite.no";
$subject = "Reparasjon av " . $_REQUEST['type'] . " fra mysite.no";
$types = if(!empty($_REQUEST['type'])) {echo($_REQUEST['type'] . ". ");};
$reps = if(!empty($_REQUEST['rep'])) {echo($_REQUEST['rep']);};
$message =  $types . . $reps . "

Kommentarer:
" . $_REQUEST['kommentarer'] . "

Fra:
" . $_REQUEST['navn'] . "
Telefon: " . $_REQUEST['telefon'] . "
Email: " . $_REQUEST['email'] . "
Bosted: " . $_REQUEST['bosted'];
$headers =  "From: " . $_REQUEST['email'] . "
" . 'MIME-Version: 1.0' . "
" . 'Content-type: text/plain; charset=UTF-8' . "
";
if (mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $headers)) {
   header( 'Location: http://www.mysite.no/' );
  } else {
   header( 'Location: http://www.mysite.no/' );
  }
?>

It says there's a T_IF error in line 4. What's the problem?

  • 写回答

5条回答 默认 最新

  • douping1825 2011-09-08 21:53
    关注

    You can't use if there, it's a syntax error. Technically if is a statement, not an expression. That means you can't use it in an assignment like $types = if (...).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器