I'm pretty sure this is a very basic question to all of you, but i'm new with php, and i don't really get it... basically i've created a function in which i need to pass two parameters.
My functions is this:
function displayRoomDetails($customerRooms, $test)
{
foreach ($customerRooms as $room) {
$test.= $room->name;
};
}
it is a very basic function, but will do for this example.
Now, i'm creating templates to display several information, and i have 3 different layout where i need to display the same info but styled differently, so my approach was:
template1 .= '<span>';
if (!$customerRooms == "") {
displayRoomDetails($customerRooms,"template1");
};
template1 .= '</span>';
It should be pretty easy to understand, basically i'm calling the same functions in all the different templates passing as a parameter the template name and trying to append the results to the right template.
The problem i've got is this: According to this example here -> http://www.w3schools.com/php/showphp.asp?filename=demo_function3
i should be able to do this exactly like i did, but when i try, when i debug my function, $template doesn't take the passed value as i though it would, but it is still called $test and not $template1...
What am i doing wrong?
Thanks
displayRoomDetails($customerRooms,$template1");if (!$customerRooms == "")the variable is being cast to boolean and inverted but the result is not being assigned to anything. You're still comparing$customerRooms == ""you probably needif($customerRooms !== "")