PHP user defind function - Mostlikers

24 July, 2014

PHP user defind function

PHP user defind function reduce program code. create your own function pass the parameters value to check the conditions. PHP gives you option to pass your parameters inside a function. You can pass as many as parameters.



Syntax

function name()
{
//own function code
}




Sample code

<?php
function month()
{
   $months = array('jan','feb');
   foreach($months as $month)
    {
    echo "<option value='".$month."'>".$month."</option>";  
    }   
}
?>

<select id="month" name="month">
  <option>select month</option>
  <?php echo month(); ?>
</select>


No comments:

Post a comment