Jump to content

Fatal error: Function name must be a string


sspence65

Recommended Posts

I'm clearly doing something wrong. I ported this piece of code from one I wrote in VBScript (where it works great), but I'm not as familiar with php syntax. Hopefully you can see where I'm going with this. I want to end up with a variable that contains the string of Sh0413C

 

$monthCode = array("02", "03", "04", "06", "09", "10", "10", "11", "11", "12", "12", "01");
$monthLetterCode = array("A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M");

$realMonthCode = date("n"); 
$labelYearCode = date("y");
$arrayMonthCode = $realMonthCode - 1;
$labelMonthCode = $monthCode(arrayMonthCode);
$labelLetterCode = $monthLetterCode(arrayMonthCode);
$myString = "Sh" . $labelMonthCode . $labelYearCode . $labelLetterCode;

 

 

$monthCode(arrayMonthCode) is telling PHP to use the value in the variable $monthCode as the name of a function to call and pass it the constant named arrayMonthCode. PHP uses square-brackets for array subscripts/keys, and you need the dollar-sign on the subscript to make it a variable reference.
$monthCode = array("02", "03", "04", "06", "09", "10", "10", "11", "11", "12", "12", "01");
$monthLetterCode = array("A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M");

$realMonthCode = date("n");
$labelYearCode = date("y");
$arrayMonthCode = $realMonthCode - 1;
$labelMonthCode = $monthCode[$arrayMonthCode]; #MAD# Changed
$labelLetterCode = $monthLetterCode[$arrayMonthCode]; #MAD# Changed
$myString = "Sh" . $labelMonthCode . $labelYearCode . $labelLetterCode;
I changed lines 7 and 8.

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.