简体   繁体   中英

empty quotes in $_POST array php

This is the entire contents of my $_Post array

'name' => 'Jon Doe'
'email' => 'jon@jondoe.com' 
'age' => 22
'action' => ''

What value will $action have after the following PHP statement is executed?

$action = (empty($_POST['action'])) ? 'default' : $_POST['action'];

如果 (强调)代码示例是$ _POST数组的输出,则三元表达式后的值将为'default'...尽管值得注意的是您不需要条件周围的括号,因此可以更改它到:

$action = empty($_POST['action']) ? 'default' : $_POST['action'];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM