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
https://forums.phpfreaks.com/topic/263245-echo-inside-a-function/
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 "";
}
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.