How can I echo multiple tasks if a common WordPress function exists.
For example, I want to reduce the following:
<?php if (function_exists ('pluginName')) echo someName (1); ?>
<?php if (function_exists ('pluginName')) echo someName (2); ?>
<?php if (function_exists ('pluginName')) echo someName (3); ?>
<?php if (function_exists ('pluginName')) echo someName (4); ?>
into a single query like this:
<?php if (function_exists ('pluginName')) echo someName (1); someName (2); someName (3); someName (4); ?>
What is the right way to do it?
How can I echo multiple tasks if a common WordPress function exists.
For example, I want to reduce the following:
<?php if (function_exists ('pluginName')) echo someName (1); ?>
<?php if (function_exists ('pluginName')) echo someName (2); ?>
<?php if (function_exists ('pluginName')) echo someName (3); ?>
<?php if (function_exists ('pluginName')) echo someName (4); ?>
into a single query like this:
<?php if (function_exists ('pluginName')) echo someName (1); someName (2); someName (3); someName (4); ?>
What is the right way to do it?
Share Improve this question edited May 12, 2016 at 12:19 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked May 11, 2016 at 18:13 AndrewL64AndrewL64 2034 silver badges18 bronze badges 4- 1 Brackets may help. See second example - the one with multiple statements. – Howdy_McGee ♦ Commented May 11, 2016 at 18:17
- Something like this? -> <?php if (function_exists ('pluginName')) { echo someName (7); echo someName (8); echo someName (9); } ?> – AndrewL64 Commented May 11, 2016 at 18:21
- 1 Yup, that'll do it. – Howdy_McGee ♦ Commented May 11, 2016 at 18:21
- Thank you good sir. Do add that as the answer and I'll mark it as correct. – AndrewL64 Commented May 11, 2016 at 18:23
1 Answer
Reset to default 0As @Howdy_McGee mentioned in the comments, you can just wrapped the multiple commands you want to run within curly brackets like this:
<?php if (function_exists ('pluginName')) { echo someName (7); echo someName (8); echo someName (9); } ?>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742359785a4429160.html
评论列表(0条)