isset PHP isset($_GET['something']) ? $_GET['something'] : ''

前端 未结 8 1429
清酒与你
清酒与你 2020-12-13 04:02

I am looking to expand on my PHP knowledge, and I came across something I am not sure what it is or how to even search for it. I am looking at php.net isset code, and I see

8条回答
  •  借酒劲吻你
    2020-12-13 04:46

    From php 7 you can write it even shorter:

    $age = $_GET['age']) ?? 27;
    

    And this means if age param is provided in the url it will be set to $age var, or will default to 27

    See all new features of php 7

提交回复
热议问题