dongqi3533 2014-02-08 16:18
浏览 22
已采纳

php语法命名,我想看看它是否正确

Hey I've been reviewing over w3schools and I just want to check if my naming of syntax is right

if someone can check it or help me out

<?php

if (isset($_POST['name']) && isset($_POST['name2'])) {
    $num=$_POST['name'];
    $num2=$_POST['name2'];
    echo  $num . ' multiplyed by '. $num2 . ' = '.$num*$num2;
}

else{
    echo '';
}


?>

the if is a condition statement?

isset is function

$_POST[name] is inside the parameter and it is a global variable (question what exactly is the definition of a global variable)

$num and $num2 are variables

name and name2 are marks from the HTML name, but what is the correct definition of name and name2

  • 写回答

1条回答 默认 最新

  • dongou3158 2014-02-08 18:23
    关注

    no. - if in PHP it is called a construct. But many would argue it okay to call a conditional statement. A conditional statement is really the statement inside the if block. As you can see we actully have multiple statements.

    if(condition) { // <- This is a if statement.
        statement // the statement is conditional.
    

    yes - isset is a native php function

    yes - $num and $num2 are variables. (if you do not know all types a variable can be in PHP, now would be a great time to learn.)

    Lastly "name and name2 are marks from the HTML name, but what is the correct definition of name and name2" no - are called keys, array index or subscript. These provide a way to define which specific index in a array we are using.

    $_POST is a native superglobal variable of the type array. A superglobal is accessable from all scopes. If you have not yet encountered what scopes are, no worries, you will as soon.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line