These are usually ideal scenarios for entering and exiting from PHP mode:
?> <select name="type" onchange="(return location.href='.?&class=.'+this.value;)" id="manage_ads"> <option value="ads">Paid To Click Ads</option> <option value="banner_ads">Banner Ad</option> <option value="featured_ads">Featured Text Ads</option> <option value="featured_link">Featured Link Ads</option> </select> <?php
Despite the fact that this system is often used, this strategy can be implemented even within the framework of functions and methods:
function createSelectControl($name, array $options) { ?> <select name="<?= $name ?>"> <?php foreach ($options as $name => $value) { createSelectOption($name, $value); } ?> </select> <?php } function createSelectOption($name, $value) { ?> <option value="<?= $value ?>"><?= $name ?></option> <?php }
Point: not echo plentiful amount of HTML (or anything for that matter) with PHP. This will save you from inevitable problems with inadequate quotes.
source share