Php 如果某物等于x,y或z

Php 如果某物等于x,y或z,php,if-statement,Php,If Statement,我正在编写一些php逻辑,并试图简化一些东西 是否可以编写如下内容: <?php if( (get_theme_mod('header_image_location')=='x', 'y' or 'z' ) {?> //Do something <?php } ?> 只需在数组()中使用 制作一个值数组,然后在数组中使用 <?php if( in_array(get_theme_mod('header_image_location'), array('

我正在编写一些php逻辑,并试图简化一些东西

是否可以编写如下内容:

<?php if( (get_theme_mod('header_image_location')=='x', 'y' or 'z' ) {?> 
    //Do something 
<?php } ?>
只需在数组()中使用


制作一个值数组,然后在数组中使用

<?php if( in_array(get_theme_mod('header_image_location'), array('x', 'y', 'z'))){?> 
    //Do something 
<?php } ?>

//做点什么

我们两人在同一时间发布了相同的答案!
if (in_array(get_theme_mod('header_image_location'), array('x','y','z'))) {

}
<?php if( in_array(get_theme_mod('header_image_location'), array('x', 'y', 'z'))){?> 
    //Do something 
<?php } ?>