Jump to content

Echo inside a function


ecabrera

Recommended Posts

can i echo inside a function i try to do it but doesnt work maybe i did it wrong for example

month is a function it takes 3 parameter.  birthdate_month has a number value from 1 - 12

inside the function im using switch so if birthdate_month is 1 do this if its 2 do that and so on but the function doesnt know what number is in birthdate_month only if i put a number like this

 

month(1,$birthdate_day,$birthdate_year);

if i do this it works but i dont want to do this i want it to fo it automaticly without me puting a number so is there a way to echo inside a function maybe like this but i try and doesnt work

month(echo $birthdate_month;,$birthdate_day,$birthdate_year);

Link to comment
Share on other sites

nope heres the function

just gives me Born on

<?php
function month($birthdate_month,$birthdate_day,$birthdate_year){

switch ($birthdate_month)
{
case 1:
echo "January $birthdate_day, $birthdate_year";
  break;
case 2:
echo "Febuary $birthdate_day, $birthdate_year";
  break;
case 3:
echo "March $birthdate_day, $birthdate_year";
  break;
  case 4:
echo "April $birthdate_day, $birthdate_year";
  break;
  case 5:
echo "May $birthdate_day, $birthdate_year";
  break;
  case 6:
echo "June $birthdate_day, $birthdate_year";
  break;
  case 7:
echo "July $birthdate_day, $birthdate_year";
  break;
  case 8:
echo "August $birthdate_day, $birthdate_year";
  break;
  case 9:
echo "September $birthdate_day, $birthdate_year";
  break;
  case 10:
echo "October $birthdate_day, $birthdate_year";
  break;
  case 12:
echo "November $birthdate_day, $birthdate_year";
  break;
  case 12:
echo "December $birthdate_day, $birthdate_year";
  break;
default:
  echo "";
}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.