PHP: a short cut for isset and !empty?

后端 未结 11 2082
余生分开走
余生分开走 2021-02-09 13:45

I wonder if there any better ideas to solve the problem below,

I have a form with a number of input fields, such as,



        
11条回答
  •  独厮守ぢ
    2021-02-09 14:07

    It is an interesting question and I await the answers.

    However, little trick, you can do inline :

    $pg_title = isset($_POST['pg_title']) && !empty($_POST['pg_title']) ? $_POST['pg_title'] : null;
    

提交回复
热议问题