/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php // Shorthand notation for if/else statements, basic example below: $myGender == 'male' ? 'i am male' : 'I am female' ?> <!-- can be used inline, such as: --> <select name="gender"> <option value="female" <?php echo ($myGender == 'female' ? 'selected' : ''); ?>>Female</option> <option value="male" <?php echo ($myGender == 'male' ? 'selected' : ''); ?>>Male</option> </select> <?php // it can also be used to assign a value to a variable: $is_admin = ($user['permissions'] == 'admin' ? true : false); // or: $x = ($myvalue == 10) ? 'the value is 10' : 'the value is not 10'; ?>