Hey all, I have a very strange problem with an object I'm working with. The constructor of the object can take two arguments, and depending on which one is empty determines how my object gets constructed. The constructor looks like this:
function Trade($trade_id = '', $info_array = array())
{
// Make sure we have at least one valid argument
if ($trade_id == '' && $info_array = '')
{
local_die(GENERAL_ERROR, 'Invalid usage of object. Constructor must have at least one valid argument.', '', __LINE__, __FILE__, '');
}
if ($trade_id == '')
{
echo $info_array;
}
else
{
// Do something else
}
}
The problem is with the line "echo $info_array"; It won't even echo that the variable is an array type. It echoes nothing.
I'm instantiating the object as such:
$info_array = array();
// First off, we take our values from post and create a new trade object
foreach($_POST as $key => $value)
{
$info_array[$key] = $value;
}
$trade = new Trade('', $info_array);
I'm dumping the POST variables into another array because I can't seem to pass $_POST as an argument, so I dump it into a local array and pass that.
The reason this is so weird is because I have another object (for other stuff) that operates the exact same way in how it's constructed. $_POST is put into a local array in the exact same way, the object is created the same way, hell, even the constructors are exactly the same in all but names, so I don't understand why it's not working. I've triple checked my syntax and all is clear. I simply do not understand why this isn't working, and I'm hoping I can get some clarification on it.
I can easily provide more code if necessary. Thanks in advance.
James